From afb4e5d5f64be21b5838d1714dc9b33133c6ab37 Mon Sep 17 00:00:00 2001 From: Talon Date: Thu, 27 Jul 2023 20:18:28 -0600 Subject: [PATCH] LSP works! --- fnl/lazy-setup.fnl | 93 +++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/fnl/lazy-setup.fnl b/fnl/lazy-setup.fnl index 471c545..46dc6b8 100644 --- a/fnl/lazy-setup.fnl +++ b/fnl/lazy-setup.fnl @@ -34,44 +34,59 @@ (let [telescope (require :telescope)] (pcall (telescope.load_extension :fzf))) -(let [treesitter (require :nvim-treesitter.configs)] - (treesitter.setup - {:ensure_installed [:c :lua :vim :vimdoc :query :fennel] - :sync_install false - :auto_intstall false - :ignore_install [] - :highlight {:enable true} - :indent {:enable true}})) +;; Syntax support via Treesitter +;; NOTE: if you add a language to treesitter for syntax highlighting or otherwise +;; consider also adding the LSP via Mason below... +(let + [treesitter (require :nvim-treesitter.configs)] + (treesitter.setup + {:ensure_installed [:c :lua :vim :vimdoc :query ; required + :fennel] ; add new languages here + :sync_install false + :auto_intstall false + :ignore_install [] ; could :ensure_installed :all, then ignore unwanted. + :highlight {:enable true} + :indent {:enable true}})) +;; Language Server Protocols via Mason ;; TODO fix lua_ls checking .fnl files? -;; (let -;; [neodev (require :neodev) -;; mason (require :mason) -;; mason-lspconfig (require :mason-lspconfig) -;; servers -;; {:lua_ls {:Lua {:workspace {:checkThirdParty false} :telemetry {:enable false}}} -;; :fennel_language_server {:filetypes [:fennel]} -;; :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)] -;; (server.setup -;; {:capabilities (vim.lsp.protocol.make_client_capabilities) -;; :on_attach on_attach -;; :settings (. servers server_name) -;; :filetypes (or (. servers server_name :filetypes) []) }))) -;; ])) +(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)] + (server.setup + {:capabilities (vim.lsp.protocol.make_client_capabilities) + :on_attach on_attach + :settings (. servers server_name) + :filetypes (or (. servers server_name :filetypes) []) }))) + ]))