helm/home/profiles/nvim/config/fnl/conf/lsp.fnl

101 lines
3.8 KiB
Plaintext
Raw Normal View History

(import-macros {: do-req } :lib/macros)
2024-08-25 23:44:07 -07:00
(local lspkind (require :lspkind))
(local lspconfig (require :lspconfig))
(local lspsaga (require :lspsaga))
2024-08-25 23:44:07 -07:00
(local cmp (require :cmp))
(local nvim (require :lib/nvim))
; (local lspfuzzy (require :lspfuzzy))
2024-08-25 23:44:07 -07:00
; (local sg (require :sg))
; (local lsputil (require :lspconfig/util))
; (local navic (require :nvim-navic))
(lspsaga.setup {:border_style "rounded"
:code_action_icon ""
:code_action_num_shortcut true
:code_action_lightbulb {
:enable false
}
; show outline
:show_outline {
:win_position "right"
:auto_enter true
:auto_preview true
:virt_text "┃"
:jump_key "o"
; auto refresh when change buffer
:auto_refresh true
}
})
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}
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})
(local lsps [:nil_ls :terraform_lsp :fennel_ls :tsserver])
(each [index lsp (ipairs lsps)]
((. (. lspconfig lsp) :setup) {}))
2024-08-25 23:44:07 -07:00
; null-ls
(let [null-ls (require :null-ls)]
(null-ls.setup {:sources [;null-ls.builtins.diagnostics.shellcheck
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