(local lsp (require :lspconfig)) (local {: merge} (require :nvrc.utils)) (local colors (require :nvrc.colors)) (fn on_attach [client bufnr] (if client.server_capabilities.document_highlight (do (vim.api.nvim_exec "augroup lsp_document_highlight autocmd! * autocmd CursorMoved lua vim.lsp.buf.clear_references() augroup END" false)))) (fn better_root_pattern [patterns except-patterns] "match path if one of the given patterns is matched, EXCEPT if one of the except-patterns is matched" (fn [path] (when (not ((lsp.util.root_pattern except-patterns) path)) ((lsp.util.root_pattern patterns) path)))) (local default_capabilities (vim.lsp.protocol.make_client_capabilities)) (fn init_lsp [lsp-name ?opts] "initialize a language server with defaults" (let [merged-opts (merge {: on_attach :capabilities default_capabilities} (or ?opts {}))] ((. lsp lsp-name :setup) merged-opts))) (tset vim.lsp.handlers :textDocument/publishDiagnostics (vim.lsp.with vim.lsp.diagnostic.on_publish_diagnostics {:update_in_insert false :virtual_text {:prefix "-"} :signs false})) (init_lsp :hls) (init_lsp :ltex)