52 lines
1.8 KiB
Fennel
52 lines
1.8 KiB
Fennel
;; Language Server Protocols via Mason
|
|
(let
|
|
[neodev (require :neodev)
|
|
mason (require :mason)
|
|
mason-lspconfig (require :mason-lspconfig)
|
|
servers
|
|
{:lua_ls
|
|
{:filetypes [:lua]
|
|
:Lua
|
|
{:workspace {:checkThirdParty false} }
|
|
:telemetry {:enable false}
|
|
:diagnostics {:globals
|
|
[:vim
|
|
]}}
|
|
:fennel_language_server
|
|
{:filetypes [:fennel]
|
|
:fennel
|
|
{:workspace {:library (vim.api.nvim_list_runtime_paths)}
|
|
:diagnostics {:globals
|
|
[:vim
|
|
]}}}
|
|
:bashls {:filetypes [:bash]}
|
|
}
|
|
on_attach (fn [_ bufnr]
|
|
(let
|
|
[nmap #(vim.keymap.set :n $1 $2 {:buffer bufnr :desc (.. "LSP: " $3)})
|
|
telescope (require :telescope.builtin)
|
|
]
|
|
(nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton")
|
|
(nmap :gr telescope.lsp_references "[G]o to [R]eferences")
|
|
(nmap :gI vim.lsp.buf.implementation "[G]o to [I]mplementation")
|
|
(vim.api.nvim_buf_create_user_command bufnr "Format"
|
|
#(vim.lsp.buf.format)
|
|
"Format current buffer with LSP")))
|
|
]
|
|
(neodev.setup)
|
|
(mason.setup)
|
|
(mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers)})
|
|
(mason-lspconfig.setup_handlers
|
|
[(fn [server_name] (let
|
|
[server (. (require :lspconfig) server_name)
|
|
cmp-nvim-lsp (require :cmp_nvim_lsp)
|
|
settings (. servers server_name)
|
|
]
|
|
(server.setup
|
|
{:capabilities (cmp-nvim-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))
|
|
:on_attach on_attach
|
|
:settings settings
|
|
:filetypes (or settings.filetypes [])})))
|
|
]))
|
|
|