2024-08-26 23:09:08 -07:00
|
|
|
(import-macros {: do-req } :lib/macros)
|
2024-08-25 23:44:07 -07:00
|
|
|
(local lspkind (require :lspkind))
|
|
|
|
(local lspconfig (require :lspconfig))
|
2024-08-27 19:45:20 -07:00
|
|
|
; (local lspsaga (require :lspsaga))
|
2024-08-25 23:44:07 -07:00
|
|
|
(local cmp (require :cmp))
|
|
|
|
(local nvim (require :lib/nvim))
|
2024-08-26 23:15:22 -07:00
|
|
|
; (local lspfuzzy (require :lspfuzzy)) ; Not available on Nix
|
2024-08-25 23:44:07 -07:00
|
|
|
; (local sg (require :sg))
|
|
|
|
; (local lsputil (require :lspconfig/util))
|
2024-08-26 23:09:08 -07:00
|
|
|
|
2024-08-27 19:45:20 -07:00
|
|
|
;(lspsaga.setup {:border_style "rounded"
|
|
|
|
; :code_action_icon ""
|
|
|
|
; :code_action_num_shortcut false
|
|
|
|
; :ui {:code_action ""}
|
|
|
|
; :show_outline {:enable false}))
|
|
|
|
;
|
|
|
|
;(nvim.opt :winbar nil)
|
2024-08-27 19:18:33 -07:00
|
|
|
|
|
|
|
(local signs {:Error " "
|
|
|
|
:Warn " "
|
|
|
|
:Hint " "
|
|
|
|
:Info " "})
|
|
|
|
(each [t icon (pairs signs)]
|
|
|
|
(let [hl (.. "DiagnosticSign" t)]
|
|
|
|
(vim.fn.sign_define hl {:text icon
|
|
|
|
:texthl hl
|
|
|
|
:numhl hl})))
|
2024-08-24 03:51:29 -07:00
|
|
|
|
2024-08-25 23:44:07 -07:00
|
|
|
(tset vim.lsp.handlers
|
|
|
|
:textDocument/hover
|
|
|
|
(vim.lsp.with vim.lsp.handlers.hover
|
|
|
|
{:focusable false :border "rounded"}))
|
|
|
|
(tset vim.lsp.handlers
|
|
|
|
:textDocument/signatureHelp
|
|
|
|
(vim.lsp.with vim.lsp.handlers.signature_help
|
|
|
|
{:focusable false :border "rounded"}))
|
|
|
|
|
|
|
|
(local capabilities (let [cmp_nvim_lsp (require :cmp_nvim_lsp)]
|
|
|
|
(cmp_nvim_lsp.default_capabilities)))
|
|
|
|
|
|
|
|
(local formatting-augroup (nvim.augroup :LspFormatting))
|
|
|
|
|
|
|
|
(fn goimports [wait-ms]
|
|
|
|
(let [params (vim.lsp.util.make_range_params)
|
|
|
|
result (do
|
|
|
|
(tset params :context {:only [:source.organizeImports]})
|
|
|
|
(vim.lsp.buf_request_sync 0 :textDocument/codeAction params wait-ms))]
|
|
|
|
(each [_ res (pairs (or result {}))]
|
|
|
|
(each [_ r (pairs (or res.result {}))]
|
|
|
|
(if r.edit
|
|
|
|
(vim.lsp.util.apply_workspace_edit r.edit "utf-16")
|
|
|
|
(vim.lsp.buf.execute_command r.command))))
|
|
|
|
(vim.lsp.buf.format)))
|
|
|
|
|
|
|
|
(fn on-attach [client bufnr]
|
|
|
|
(let [filetype (vim.api.nvim_buf_get_option 0 "filetype")]
|
|
|
|
(if (client.supports_method "textDocument/formatting")
|
|
|
|
(do (nvim.autocmd "BufWritePre"
|
|
|
|
{:group formatting-augroup
|
|
|
|
:buffer bufnr
|
|
|
|
:callback (fn [_] (if (= filetype "go")
|
|
|
|
(goimports 2000)
|
|
|
|
(vim.lsp.buf.format {:bufnr bufnr})))})))))
|
|
|
|
|
|
|
|
(lspconfig.gopls.setup
|
|
|
|
{:capabilities capabilities
|
|
|
|
:codelens {:generate true :gc_details true}
|
|
|
|
:semanticTokens true
|
2024-08-26 23:09:08 -07:00
|
|
|
:flags {:debounce_text_changes 200}
|
2024-08-25 23:44:07 -07:00
|
|
|
:analyses {:unusedparams true
|
|
|
|
:unusedvariables true
|
|
|
|
:unusedwrite true
|
|
|
|
:nilness true
|
|
|
|
:unusedwrite true
|
|
|
|
:useany true}
|
|
|
|
:completeUnimported true
|
|
|
|
:staticcheck true
|
|
|
|
:experimentalPostfixCompletions true
|
|
|
|
:hints {:constantValues true
|
|
|
|
:functionTypeParameters true
|
|
|
|
:assignVariablesTypes true
|
|
|
|
:compositeLiteralTypes true
|
|
|
|
:compositeLiteralFields true
|
|
|
|
:parameterNames true
|
|
|
|
:rangeVariableTypes true}
|
|
|
|
:on_attach on-attach})
|
|
|
|
|
2024-08-26 23:15:22 -07:00
|
|
|
(local lsps [:nil_ls :terraform_lsp :fennel_ls :tsserver :starbin])
|
2024-08-26 23:09:08 -07:00
|
|
|
(each [index lsp (ipairs lsps)]
|
|
|
|
((. (. lspconfig lsp) :setup) {}))
|
2024-08-25 23:44:07 -07:00
|
|
|
|
2024-08-26 23:09:08 -07:00
|
|
|
; null-ls
|
|
|
|
(let [null-ls (require :null-ls)]
|
2024-08-26 23:15:22 -07:00
|
|
|
(null-ls.setup {:sources [; TODO fix these
|
|
|
|
;null-ls.builtins.diagnostics.shellcheck
|
2024-08-26 23:09:08 -07:00
|
|
|
null-ls.builtins.diagnostics.commitlint]}))
|
|
|
|
;null-ls.builtins.diagnostics.jsonlint]}))
|
|
|
|
;(null-ls.builtins.diagnostics.proselint.with {:filetypes ["vimwiki" "mail"]})]}))
|
2024-08-25 23:44:07 -07:00
|
|
|
|