summaryrefslogtreecommitdiff
path: root/fnl/config/lsp
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-08 02:49:49 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-08 02:49:49 +0100
commit86fc163e549d78136855ac2b45e91ffb2f43affc (patch)
tree20fab78a2ff2635af5ac95f2b2a11d9d07ace0e1 /fnl/config/lsp
parent0d7f782cb4e68cff000beb00e8ab64308a66f3f0 (diff)
Refactor config loading
Diffstat (limited to 'fnl/config/lsp')
-rw-r--r--fnl/config/lsp/lspconfig.fnl56
-rw-r--r--fnl/config/lsp/mason.fnl14
-rw-r--r--fnl/config/lsp/null-ls.fnl70
3 files changed, 79 insertions, 61 deletions
diff --git a/fnl/config/lsp/lspconfig.fnl b/fnl/config/lsp/lspconfig.fnl
index b7143ab..74faa26 100644
--- a/fnl/config/lsp/lspconfig.fnl
+++ b/fnl/config/lsp/lspconfig.fnl
@@ -1,30 +1,40 @@
;; Setup of lsps.
-(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)))}))
+(fn on-attach []
+ (vim.api.nvim_create_autocmd :LspAttach
+ {:callback (fn [args]
+ (let [keymaps (require :config.lsp.keymaps)
+ bufnr (. args :buf)]
+ (keymaps.on-attach bufnr)))}))
-(defn- capabilities []
- (let [cmp-lsp (util.prequire :cmp_nvim_lsp)]
+(fn capabilities []
+ (let [cmp-lsp (require :cmp_nvim_lsp)]
(cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))))
-(defn- mason-opts [servers]
+(fn 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)))]))
+(fn setup []
+ (require :config.lsp.diagnostics)
+ (let [lspconfig (require :lspconfig)
+ mason-lspconfig (require :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)))])))
+
+{1 :neovim/nvim-lspconfig
+ :event :BufReadPre
+ :dependencies [:mason.nvim
+ :williamboman/mason-lspconfig.nvim
+ :b0o/SchemaStore.nvim
+ :hrsh7th/cmp-nvim-lsp]
+ :config (fn []
+ (setup))}
diff --git a/fnl/config/lsp/mason.fnl b/fnl/config/lsp/mason.fnl
index adc60a4..fd40102 100644
--- a/fnl/config/lsp/mason.fnl
+++ b/fnl/config/lsp/mason.fnl
@@ -1,9 +1,11 @@
;; Mason manages external tooling, e.g. lsp, formatters, and linters.
-(module config.lsp.mason {autoload {util config.util}})
-(def- opts {:ui {:icons {:package_installed "✓"
- :package_pending "➜"
- :package_uninstalled "✗"}}
- :max_concurrent_installers 10})
+(local opts {:ui {:icons {:package_installed " "
+ :package_pending " "
+ :package_uninstalled " "}}
+ :max_concurrent_installers 10})
-(util.setup :mason opts)
+{1 :williamboman/mason.nvim
+ :cmd :Mason
+ :keys [{1 :<leader>m 2 :<cmd>Mason<cr> :desc :Mason}]
+ :config opts}
diff --git a/fnl/config/lsp/null-ls.fnl b/fnl/config/lsp/null-ls.fnl
index fd3a61d..2d03b0d 100644
--- a/fnl/config/lsp/null-ls.fnl
+++ b/fnl/config/lsp/null-ls.fnl
@@ -1,35 +1,41 @@
;; Adds LSP diagnostics and formatting.
-(module config.lsp.null-ls {autoload {util config.util}})
-(def- mason-opts {:ensure_installed nil
- :automatic_installation true
- :automatic_setup false})
+(local 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
- :sources [diagnostics.codespell
- diagnostics.cpplint
- diagnostics.gitlint
- diagnostics.hadolint
- diagnostics.jsonlint
- diagnostics.misspell
- diagnostics.ruff
- diagnostics.selene
- diagnostics.shellcheck
- diagnostics.sqlfluff
- diagnostics.write_good
- diagnostics.yamllint
- formatting.fnlfmt
- formatting.markdownlint
- formatting.prettierd
- formatting.ruff
- formatting.rustfmt
- formatting.shellharden
- formatting.shfmt
- formatting.sqlfluff
- formatting.stylua
- formatting.terraform_fmt]}))
- (mason-null-ls.setup mason-opts))
+(fn setup []
+ (let [null-ls (require :null-ls)
+ mason-null-ls (require :mason-null-ls)]
+ (let [formatting null-ls.builtins.formatting
+ diagnostics null-ls.builtins.diagnostics]
+ (null-ls.setup {:debug false
+ :sources [diagnostics.codespell
+ diagnostics.cpplint
+ diagnostics.gitlint
+ diagnostics.hadolint
+ diagnostics.jsonlint
+ diagnostics.misspell
+ diagnostics.ruff
+ diagnostics.selene
+ diagnostics.shellcheck
+ diagnostics.sqlfluff
+ diagnostics.write_good
+ diagnostics.yamllint
+ formatting.fnlfmt
+ formatting.markdownlint
+ formatting.prettierd
+ formatting.ruff
+ formatting.rustfmt
+ formatting.shellharden
+ formatting.shfmt
+ formatting.sqlfluff
+ formatting.stylua
+ formatting.terraform_fmt]}))
+ (mason-null-ls.setup mason-opts)))
+
+{1 :jose-elias-alvarez/null-ls.nvim
+ :dependencies [:mason.nvim :jayp0521/mason-null-ls.nvim]
+ :event :BufReadPre
+ :config (fn []
+ (setup))}