2024-08-25 23:44:07 -07:00
|
|
|
; (local lspfuzzy (require :lspfuzzy))
|
|
|
|
(local lspkind (require :lspkind))
|
|
|
|
(local lspconfig (require :lspconfig))
|
|
|
|
(local cmp (require :cmp))
|
|
|
|
(local nvim (require :lib/nvim))
|
|
|
|
; (local sg (require :sg))
|
|
|
|
; (local lsputil (require :lspconfig/util))
|
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
|
|
|
|
:flags { :debounce_text_changes 200}
|
|
|
|
: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})
|
|
|
|
|
|
|
|
|
|
|
|
; # local servers = { 'clojure_lsp', 'terraform_lsp', 'zls', 'pyright', 'rust_analyzer', 'tsserver', 'lua_ls', 'nil_ls', 'gopls'}
|
|
|
|
; # for _, lsp in ipairs(servers) do
|
|
|
|
; # lspconfig[lsp].setup {}
|
|
|
|
; # on_attach = function(client, bufnr)
|
|
|
|
; # format.on_attach(client)
|
|
|
|
; # navic.attach(client, bufnr)
|
|
|
|
; # end,
|
|
|
|
; # capabilities = capabilities,
|
|
|
|
; #
|
|
|
|
; # end)
|
|
|
|
;; Diagnostics Config I don't yet understand
|
2024-08-24 03:51:29 -07:00
|
|
|
; Set Diagnostics
|
|
|
|
; local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
|
|
|
; for type, icon in pairs(signs) do
|
|
|
|
; local hl = "DiagnosticSign" .. type
|
|
|
|
; vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl})
|
|
|
|
; end
|
2024-08-25 23:44:07 -07:00
|
|
|
|
|
|
|
; vim.g.diagnostics_active = true
|
|
|
|
; function _G.toggle_diagnostics()
|
|
|
|
; if vim.g.diagnostics_active then
|
|
|
|
; vim.g.diagnostics_active = false
|
|
|
|
; vim.lsp.diagnostic.clear(0)
|
|
|
|
; vim.lsp.handlers["textDocument/publishDiagnostics"] = function() end
|
|
|
|
; else
|
|
|
|
; vim.g.diagnostics_active = true
|
|
|
|
; vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
|
|
|
; vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
|
|
; virtual_text = true,
|
|
|
|
; signs = true,
|
|
|
|
; underline = true,
|
|
|
|
; update_in_insert = false,
|
|
|
|
; }
|
|
|
|
; )
|
|
|
|
; end
|
|
|
|
; end
|
|
|
|
;
|
|
|
|
; vim.diagnostic.config({
|
|
|
|
; signs = true,
|
|
|
|
; update_in_insert = false,
|
|
|
|
; underline = false,
|
|
|
|
; severity_sort = true,
|
|
|
|
; float = {
|
|
|
|
; focusable = false,
|
|
|
|
; style = 'minimal',
|
|
|
|
; border = 'rounded',
|
|
|
|
; source = 'always',
|
|
|
|
; },
|
|
|
|
; })
|