LSP works!

This commit is contained in:
Talon 2023-07-27 20:18:28 -06:00
parent b292fcca52
commit afb4e5d5f6

View file

@ -34,44 +34,59 @@
(let [telescope (require :telescope)] (let [telescope (require :telescope)]
(pcall (telescope.load_extension :fzf))) (pcall (telescope.load_extension :fzf)))
(let [treesitter (require :nvim-treesitter.configs)] ;; 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 (treesitter.setup
{:ensure_installed [:c :lua :vim :vimdoc :query :fennel] {:ensure_installed [:c :lua :vim :vimdoc :query ; required
:fennel] ; add new languages here
:sync_install false :sync_install false
:auto_intstall false :auto_intstall false
:ignore_install [] :ignore_install [] ; could :ensure_installed :all, then ignore unwanted.
:highlight {:enable true} :highlight {:enable true}
:indent {:enable true}})) :indent {:enable true}}))
;; Language Server Protocols via Mason
;; TODO fix lua_ls checking .fnl files? ;; TODO fix lua_ls checking .fnl files?
;; (let (let
;; [neodev (require :neodev) [neodev (require :neodev)
;; mason (require :mason) mason (require :mason)
;; mason-lspconfig (require :mason-lspconfig) mason-lspconfig (require :mason-lspconfig)
;; servers servers
;; {:lua_ls {:Lua {:workspace {:checkThirdParty false} :telemetry {:enable false}}} {:lua_ls
;; :fennel_language_server {:filetypes [:fennel]} {:filetypes [:lua]
;; :bashls {:filetypes [:bash]} :Lua
;; } {:workspace {:checkThirdParty false}
;; on_attach (fn [_ bufnr] :telemetry {:enable false}}
;; (let :diagnostics {:globals [:vim]}}
;; [nmap #(vim.keymap.set :n $1 $2 {:buffer bufnr :desc (.. "LSP: " $3)}) :fennel_language_server
;; telescope (require :telescope.builtin) {:filetypes [:fennel]
;; ] :fennel
;; (nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton") {:workspace {:library (vim.api.nvim_list_runtime_paths)}
;; (nmap :gr telescope.lsp_references "[G]o to [R]eferences") :diagnostics {:globals [:vim]}}}
;; (nmap :gI vim.lsp.buf.implementation "[G]o to [I]mplementation") :bashls {:filetypes [:bash]}
;; (vim.api.nvim_buf_create_user_command bufnr "Format" #(vim.lsp.buf.format) }
;; "Format current buffer with LSP"))) on_attach (fn [_ bufnr]
;; ] (let
;; (neodev.setup) [nmap #(vim.keymap.set :n $1 $2 {:buffer bufnr :desc (.. "LSP: " $3)})
;; (mason.setup) telescope (require :telescope.builtin)
;; (mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers)}) ]
;; (mason-lspconfig.setup_handlers (nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton")
;; [(fn [server_name] (let [server (. (require :lspconfig) server_name)] (nmap :gr telescope.lsp_references "[G]o to [R]eferences")
;; (server.setup (nmap :gI vim.lsp.buf.implementation "[G]o to [I]mplementation")
;; {:capabilities (vim.lsp.protocol.make_client_capabilities) (vim.api.nvim_buf_create_user_command bufnr "Format" #(vim.lsp.buf.format)
;; :on_attach on_attach "Format current buffer with LSP")))
;; :settings (. servers server_name) ]
;; :filetypes (or (. servers server_name :filetypes) []) }))) (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) []) })))
]))