Neovim: move from lsp-installer to mason

This commit is contained in:
2023-01-31 13:13:30 -06:00
parent 04bf501caa
commit a23c581746
3 changed files with 44 additions and 41 deletions

View File

@@ -3,6 +3,7 @@
u dotfiles.util
nvim aniseed.nvim
lsp vim.lsp
lspconfig lspconfig
nu aniseed.nvim.util
cmp_nvim_lsp cmp_nvim_lsp}})
@@ -17,14 +18,14 @@
(nvim.fn.sign_define sign-level
{:texthl sign-level :text sign :numhl sign-level})))
; (define-sign :Error "☢️")
; (define-sign :Warn "⚠️")
; (define-sign :SignHint "🔎")
; (define-sign :Info "")
(define-sign :Error :X)
(define-sign :Warn "!")
(define-sign :SignHint "?")
(define-sign :Info :i)
(define-sign :Error "☢️")
(define-sign :Warn "⚠️")
(define-sign :SignHint "🔎")
(define-sign :Info "")
; (define-sign :Error :X)
; (define-sign :Warn "!")
; (define-sign :SignHint "?")
; (define-sign :Info :i)
(def core-nmappings
{:gd "lua vim.lsp.buf.definition()"
@@ -86,6 +87,8 @@
:ua [:unwind-all []]
:uw [:unwind-thread []]}})
(def server-specific-opts {})
(defn bind-client-mappings [client]
(let [client-name (a.get client :name)
mappings (a.get client-nmappings client-name)
@@ -124,9 +127,17 @@
; -- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf_request_sync(vim.api.nvim_get_current_buf(), 'workspace/executeCommand', {command = 'clean-ns', arguments = {vim.uri_from_bufnr(1), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]]
(print "LSP Client Attached."))
(when-let [lspi (require :nvim-lsp-installer)]
(def base-server-opts
(let [capabilities (cmp_nvim_lsp.default_capabilities (lsp.protocol.make_client_capabilities))]
(defn lsp-execute-command [cmd ...]
{: on_attach : capabilities :flags {:debounce_text_changes 150}}))
(defn default-server-handler [server-name]
(let [specific-opts (a.get server-specific-opts server-name {})
server (a.get lspconfig server-name)
server-opts (a.merge base-server-opts server-opts)]
(server.setup server-opts)))
(defn lsp-execute-command [cmd ...]
(let [buf-uri (vim.uri_from_bufnr 0)
cursor (vim.api.nvim_win_get_cursor 0)
r (- (a.first cursor) 1)
@@ -134,26 +145,10 @@
opts [buf-uri r c]
args (a.concat opts [...])]
(vim.lsp.buf.execute_command {:command cmd :arguments args})))
(defn setup-servers []
(lspi.on_server_ready (fn [server]
(let [opts {: on_attach
: capabilities
:flags {:debounce_text_changes 150}}]
(server:setup opts))))
;; (let [lspconfig (require :lspconfig)
;; servers (lspi.get_installed_servers)]
;; (each [_ server (pairs servers)]
;; (server.setup {:on_attach on_attach :flags {:debounce_text_changes 150} })))
)
(defn on-post-install [] (setup-servers) (nvim.ex.bufdo :e))
(setup-servers)
(set lspi.post_install_hook on-post-install)
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig
:lsp-execute-command {:return false})
(u.nnoremap :<leader>li :LspInfo)))
(comment (let [lspi (require :nvim-lsp-installer)
;lspconfig (require :lspconfig)
servers (lspi.get_installed_servers)]
(each [_ server (pairs servers)]
(a.pr server))))
(when-let [mason-lspconfig (require :mason-lspconfig)] (mason-lspconfig.setup)
(mason-lspconfig.setup_handlers {1 default-server-handler}))
(u.nnoremap :<leader>li :LspInfo)
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig
:lsp-execute-command {:return false})

View File

@@ -0,0 +1,6 @@
(module dotfiles.plugin.mason
{autoload {nvim aniseed.nvim mason mason mason-lspconf mason-lspconfig}})
(mason.setup {:ui {:icons {:package_installed "✓"}}})
(mason-lspconf.setup {:ensure_installed [:sumneko_lua]})

View File

@@ -77,7 +77,9 @@
:tpope/vim-unimpaired {}
:tpope/vim-vinegar {}
:wbthomason/packer.nvim {:mod :packer}
:williamboman/nvim-lsp-installer {}
;; :williamboman/nvim-lsp-installbuilder {}
:williamboman/mason.nvim {:mod :mason
:requires [:williamboman/mason-lspconfig.nvim]}
; NeoVim lsp server installs
; :luochen1990/rainbow {}
; :thecontinium/asyncomplete-conjure.vim {}