summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fnl/config/lsp/keymaps.fnl38
-rw-r--r--fnl/config/lsp/lspconfig.fnl68
-rw-r--r--fnl/config/lsp/mason-lspconfig.fnl8
-rw-r--r--fnl/config/lsp/mason-null-ls.fnl6
-rw-r--r--fnl/config/lsp/null-ls.fnl10
-rw-r--r--fnl/config/lsp/servers.fnl44
-rw-r--r--fnl/config/lsp/settings/jsonls.fnl10
-rw-r--r--fnl/config/lsp/settings/rust.fnl6
-rw-r--r--fnl/config/lsp/settings/sumneko-lua.fnl8
-rw-r--r--fnl/plugins.fnl36
10 files changed, 101 insertions, 133 deletions
diff --git a/fnl/config/lsp/keymaps.fnl b/fnl/config/lsp/keymaps.fnl
index 56a84a3..c60dfa9 100644
--- a/fnl/config/lsp/keymaps.fnl
+++ b/fnl/config/lsp/keymaps.fnl
@@ -1,22 +1,22 @@
;; Key mappings for lsp.
(module config.lsp.keymaps {autoload {nvim aniseed.nvim}})
-(defn keymaps [bufnr] (let [opts {:noremap true :silent true}]
- (nvim.buf_set_keymap bufnr :n :gD
- "<cmd>lua vim.lsp.buf.declaration()<CR>"
- opts)
- (nvim.buf_set_keymap bufnr :n :gd
- "<cmd>lua vim.lsp.buf.definition()<CR>"
- opts)
- (nvim.buf_set_keymap bufnr :n :gI
- "<cmd>lua vim.lsp.buf.implementation()<CR>"
- opts)
- (nvim.buf_set_keymap bufnr :n :gr
- "<cmd>lua vim.lsp.buf.references()<CR>"
- opts)
- (nvim.buf_set_keymap bufnr :n :gl
- "<cmd>lua vim.diagnostic.open_float()<CR>"
- opts)
- (nvim.buf_set_keymap bufnr :n :gs
- "<cmd>lua vim.lsp.buf.signature_help()<CR>"
- opts)))
+(defn on-attach [bufnr] (let [opts {:noremap true :silent true}]
+ (nvim.buf_set_keymap bufnr :n :gD
+ "<cmd>lua vim.lsp.buf.declaration()<CR>"
+ opts)
+ (nvim.buf_set_keymap bufnr :n :gd
+ "<cmd>lua vim.lsp.buf.definition()<CR>"
+ opts)
+ (nvim.buf_set_keymap bufnr :n :gI
+ "<cmd>lua vim.lsp.buf.implementation()<CR>"
+ opts)
+ (nvim.buf_set_keymap bufnr :n :gr
+ "<cmd>lua vim.lsp.buf.references()<CR>"
+ opts)
+ (nvim.buf_set_keymap bufnr :n :gl
+ "<cmd>lua vim.diagnostic.open_float()<CR>"
+ opts)
+ (nvim.buf_set_keymap bufnr :n :gs
+ "<cmd>lua vim.lsp.buf.signature_help()<CR>"
+ opts)))
diff --git a/fnl/config/lsp/lspconfig.fnl b/fnl/config/lsp/lspconfig.fnl
index c9baba7..b7143ab 100644
--- a/fnl/config/lsp/lspconfig.fnl
+++ b/fnl/config/lsp/lspconfig.fnl
@@ -1,40 +1,30 @@
;; Setup of lsps.
-(module config.lsp.lspconfig {autoload {util config.util lsp config.lsp.keymaps}})
-
-(defn on-attach [client bufnr] (if (= client.name :html)
- (set client.server_capabilities.document_formatting
- false))
- (lsp.keymaps bufnr))
-
-(defn capabilities []
- (let [capabilities (vim.lsp.protocol.make_client_capabilities)]
- (set capabilities.textDocument.completion.completionItem.snippetSupport
- true)
- (let [cmp-nvim-lsp (util.prequire :cmp_nvim_lsp)]
- (cmp-nvim-lsp.default_capabilities capabilities))))
-
-(defn- handler-opts [] {:on_attach on-attach :capabilities (capabilities)})
-
-(defn- jsonls-opts []
- (let [jsonls-opts (require :config.lsp.settings.jsonls)]
- (vim.tbl_deep_extend :force jsonls-opts (handler-opts))))
-
-(defn- sumneko-lua-opts []
- (let [sumneko-lua (require :config.lsp.settings.sumneko-lua)]
- (vim.tbl_deep_extend :force sumneko-lua.opts (handler-opts))))
-
-(defn- rust-opts []
- (let [rust (require :config.lsp.settings.rust)]
- (vim.tbl_deep_extend :force rust.opts (handler-opts))))
-
-(defn- get-server-opts [server]
- (match server
- :jsonls (jsonls-opts)
- :sumneko_lua (sumneko-lua-opts)
- :rust_analyzer (rust-opts)
- _ (handler-opts)))
-
-(let [lspconfig (util.prequire :lspconfig) servers (require :config.lsp.servers)]
- (each [_ server (ipairs servers)]
- (let [server-config (. lspconfig server)]
- (server-config.setup (get-server-opts server)))))
+(module config.lsp.lspconfig
+ {autoload {nvim aniseed.nvim
+ util config.util
+ keymaps config.lsp.keymaps}})
+
+(defn- on-attach []
+ (nvim.create_autocmd :LspAttach
+ {:callback (fn [args]
+ (let [bufnr (. args :buf)]
+ (keymaps.on-attach bufnr)))}))
+
+(defn- capabilities []
+ (let [cmp-lsp (util.prequire :cmp_nvim_lsp)]
+ (cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))))
+
+(defn- mason-opts [servers]
+ {:ensure_installed (vim.tbl_keys servers) :automatic_installation true})
+
+(let [lspconfig (util.prequire :lspconfig)
+ mason-lspconfig (util.prequire :mason-lspconfig)
+ servers (require :config.lsp.servers)]
+ (on-attach)
+ (mason-lspconfig.setup (mason-opts servers))
+ (mason-lspconfig.setup_handlers [(fn [server-name]
+ (let [server-config (. lspconfig
+ server-name)
+ opts (or (. servers server-name) {})]
+ (tset opts :capabilities (capabilities))
+ (server-config.setup opts)))]))
diff --git a/fnl/config/lsp/mason-lspconfig.fnl b/fnl/config/lsp/mason-lspconfig.fnl
deleted file mode 100644
index 5180549..0000000
--- a/fnl/config/lsp/mason-lspconfig.fnl
+++ /dev/null
@@ -1,8 +0,0 @@
-;; Automatic installation and updating of some lsps.
-(module config.lsp.mason-lspconfig {autoload {util config.util}})
-
-(def- servers (require :config.lsp.servers))
-
-(def- opts {:ensure_installed servers :automatic_installation true})
-
-(util.setup :mason-lspconfig opts)
diff --git a/fnl/config/lsp/mason-null-ls.fnl b/fnl/config/lsp/mason-null-ls.fnl
deleted file mode 100644
index 40eaab7..0000000
--- a/fnl/config/lsp/mason-null-ls.fnl
+++ /dev/null
@@ -1,6 +0,0 @@
-;; Automatic installation and updating lsp diagnostics etc..
-(module config.lsp.mason-null-ls {autoload {util config.util}})
-
-(def- opts {:ensure_installed nil :automatic_installation true :automatic_setup false})
-
-(util.setup :mason-null-ls opts)
diff --git a/fnl/config/lsp/null-ls.fnl b/fnl/config/lsp/null-ls.fnl
index 2df7a55..fd3a61d 100644
--- a/fnl/config/lsp/null-ls.fnl
+++ b/fnl/config/lsp/null-ls.fnl
@@ -1,7 +1,12 @@
;; Adds LSP diagnostics and formatting.
(module config.lsp.null-ls {autoload {util config.util}})
-(let [null-ls (util.prequire :null-ls)]
+(def- mason-opts {:ensure_installed nil
+ :automatic_installation true
+ :automatic_setup false})
+
+(let [null-ls (util.prequire :null-ls)
+ mason-null-ls (util.prequire :mason-null-ls)]
(let [formatting null-ls.builtins.formatting
diagnostics null-ls.builtins.diagnostics]
(null-ls.setup {:debug false
@@ -26,4 +31,5 @@
formatting.shfmt
formatting.sqlfluff
formatting.stylua
- formatting.terraform_fmt]})))
+ formatting.terraform_fmt]}))
+ (mason-null-ls.setup mason-opts))
diff --git a/fnl/config/lsp/servers.fnl b/fnl/config/lsp/servers.fnl
index 6a41f69..2403c1a 100644
--- a/fnl/config/lsp/servers.fnl
+++ b/fnl/config/lsp/servers.fnl
@@ -1,19 +1,29 @@
;; List of lsp that should be automatically installed and supported.
-[:bashls
- :clangd
- :cssls
- :dockerls
- :hls
- :html
- :jsonls
- :pyright
- :rust_analyzer
- :sqls
- :sumneko_lua
- :taplo
- :terraformls
- :texlab
- :tflint
- :yamlls
- :zk]
+{:bashls {}
+ :clangd {}
+ :cssls {}
+ :dockerls {}
+ :hls {}
+ :html {}
+ :jsonls {:init_options {:providerFormatter false}
+ :settings {:json {:schemas (let [schemastore (require :schemastore)]
+ (schemastore.json.schemas))}}
+ :setup {:commands {:Format [(fn []
+ (vim.lsp.buf.range_formatting [] [0 0]
+ [(vim.fn.line "$"
+ 0)]))]}}}
+ :pyright {}
+ :rust_analyzer {:settings {:rust-analyzer {:lens {:enable true}
+ :checkOnSave {:command :clippy}}}}
+ :sqls {}
+ :sumneko_lua {:settings {:Lua {:completion {:callSnippet :Replace}
+ :workspace {:checkThirdParty false}
+ :runtime {:version :LuaJIT
+ :path (vim.split package.path ";")}}}}
+ :taplo {}
+ :terraformls {}
+ :texlab {}
+ :tflint {}
+ :yamlls {}
+ :zk {}}
diff --git a/fnl/config/lsp/settings/jsonls.fnl b/fnl/config/lsp/settings/jsonls.fnl
deleted file mode 100644
index 55c6115..0000000
--- a/fnl/config/lsp/settings/jsonls.fnl
+++ /dev/null
@@ -1,10 +0,0 @@
-;; Json schema store catalog language server.
-(module config.lsp.settings.jsonls {autoload {util config.util}})
-
-(let [schemastore (util.prequire :schemastore)]
- {:init_options {:providerFormatter false}
- :settings {:json {:schemas (schemastore.json.schemas)}}
- :setup {:commands {:Format [(fn []
- (vim.lsp.buf.range_formatting [] [0 0]
- [(vim.fn.line "$"
- 0)]))]}}})
diff --git a/fnl/config/lsp/settings/rust.fnl b/fnl/config/lsp/settings/rust.fnl
deleted file mode 100644
index b7277a1..0000000
--- a/fnl/config/lsp/settings/rust.fnl
+++ /dev/null
@@ -1,6 +0,0 @@
-;; Configuration for rust langauage server.
-(module config.lsp.settings.rust)
-
-(def opts
- {:settings {:rust-analyzer {:lens {:enable true}
- :checkOnSave {:command :clippy}}}})
diff --git a/fnl/config/lsp/settings/sumneko-lua.fnl b/fnl/config/lsp/settings/sumneko-lua.fnl
deleted file mode 100644
index 83817f8..0000000
--- a/fnl/config/lsp/settings/sumneko-lua.fnl
+++ /dev/null
@@ -1,8 +0,0 @@
-;; Config for the sumneko-lua language server.
-(module config.lsp.settings.sumneko-lua)
-
-(def- runtime {:version :LuaJIT :path (vim.split package.path ";")})
-
-(def opts {:settings {:Lua {:completion {:callSnippet :Replace}
- :workspace {:checkThirdParty false}
- : runtime}}})
diff --git a/fnl/plugins.fnl b/fnl/plugins.fnl
index 1300255..5d3453f 100644
--- a/fnl/plugins.fnl
+++ b/fnl/plugins.fnl
@@ -42,26 +42,26 @@
:config (fn []
(require :config.neogit))}
{1 :lewis6991/gitsigns.nvim
- :event :BufReadPre
+ :event :BufReadPost
:config (fn []
(require :config.gitsigns))}
;; LSP
{1 :williamboman/mason.nvim
:cmd :Mason
:keys [{1 :<leader>m 2 :<cmd>Mason<cr> :desc :Mason}]
- :dependencies [:williamboman/mason-lspconfig.nvim]
:config (fn []
- (require :config.lsp.mason)
- (require :config.lsp.mason-lspconfig))}
+ (require :config.lsp.mason))}
{1 :jose-elias-alvarez/null-ls.nvim
:dependencies [:mason.nvim :jayp0521/mason-null-ls.nvim]
:event :BufReadPre
:config (fn []
- (require :config.lsp.null-ls)
- (require :config.lsp.mason-null-ls))}
+ (require :config.lsp.null-ls))}
{1 :neovim/nvim-lspconfig
:event :BufReadPre
- :dependencies [:mason.nvim :b0o/SchemaStore.nvim :hrsh7th/cmp-nvim-lsp]
+ :dependencies [:mason.nvim
+ :williamboman/mason-lspconfig.nvim
+ :b0o/SchemaStore.nvim
+ :hrsh7th/cmp-nvim-lsp]
:config (fn []
(require :config.lsp.diagnostics)
(require :config.lsp.lspconfig))}
@@ -71,7 +71,7 @@
(require :config.trouble))}
;; Misc plugins
{1 :nvim-orgmode/orgmode
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.orgmode))}
{1 :ojroques/nvim-bufdel :cmd :BufDel}
@@ -100,23 +100,23 @@
(require :config.lir))
:dependencies [:kyazdani42/nvim-web-devicons]}
{1 :ggandor/leap.nvim
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.leap))}
{1 :ggandor/flit.nvim
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.flit))}
{1 :windwp/nvim-spectre
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.spectre))}
{1 :junegunn/vim-slash
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.vim-slash))}
{1 :ThePrimeagen/harpoon
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.harpoon))}
;; Session plugins
@@ -126,7 +126,7 @@
(require :config.persistence))}
;; Text manipulation
{1 :numToStr/Comment.nvim
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.comment))}
{1 :kylechui/nvim-surround
@@ -134,7 +134,7 @@
:config (fn []
(require :config.surround))}
{1 :gbprod/stay-in-place.nvim
- :event :InsertEnter
+ :event :BufReadPost
:config (fn []
(require :config.stay-in-place))}
{1 :cappyzawa/trim.nvim
@@ -142,7 +142,7 @@
:config (fn []
(require :config.trim))}
{1 :max397574/better-escape.nvim
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.better-escape))}
{1 :windwp/nvim-autopairs
@@ -164,11 +164,11 @@
:config (fn []
(require :config.zen))}
{1 :kevinhwang91/nvim-bqf
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.bqf))}
{1 :s1n7ax/nvim-window-picker
- :event :VeryLazy
+ :event :BufReadPost
:config (fn []
(require :config.window-picker))}
{1 :goolord/alpha-nvim