(module user.lsp {require {nvim aniseed.nvim}}) (local lspconfig (require :lspconfig)) (local treesitter_configs (require :nvim-treesitter.configs)) (local treesitter_install (require :nvim-treesitter.install)) (local cmp (require :cmp)) (nvim.set_keymap "" :gd "lua vim.lsp.buf.definition()" {:silent true :noremap true}) (nvim.set_keymap "" :gh "lua vim.lsp.buf.hover()" {:silent true :noremap true}) (nvim.set_keymap "" :gi "lua vim.lsp.buf.implementation()" {:silent true :noremap true}) (nvim.set_keymap "" :gr "lua vim.lsp.buf.references()" {:silent true :noremap true}) (nvim.set_keymap "" :gs "lua vim.lsp.buf.signature_help()" {:silent true :noremap true}) (nvim.set_keymap "" :e "lua vim.lsp.diagnostic.show_line_diagnostics()" {:silent true :noremap true}) (lspconfig.rust_analyzer.setup {}) (lspconfig.gopls.setup {}) ; treesitter (set treesitter_install.compilers ["clang"]) (treesitter_configs.setup {:ensure_installed ["c" "cpp" "python" "go" "rust" "javascript" "typescript" "lua"] :highlight {:enable true} :indent {:enable true} :textobjects {:select {:enable true :keymaps {:ia "@parameter.inner" :oa "@parameter.outer"}} :swap {:enable true :swap_next {: "@parameter.inner"} :swap_previous {: "@parameter.inner"}}}}) ;; completion (set nvim.o.completeopt "menu,menuone,noselect") (def- cmp-src-menu-items {:buffer "buffer" :nvim_lsp "lsp" :path "path"}) (def- cmp-srcs [{:name :nvim_lsp} {:name :path} {:name :buffer}]) (cmp.setup {:formatting {:format (fn [entry item] (set item.menu (or (. cmp-src-menu-items entry.source.name) "")) item)} :mapping {: (cmp.mapping.select_prev_item) : (cmp.mapping.select_next_item) ; : (cmp.mapping.scroll_docs (- 4)) ; : (cmp.mapping.scroll_docs 4) ; : (cmp.mapping.complete) ; : (cmp.mapping.close) : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Insert :select true})} :sources cmp-srcs})