From 152fd9d787c7433cad95795992e444250cb83216 Mon Sep 17 00:00:00 2001 From: aktersnurra Date: Thu, 16 Apr 2026 15:10:52 +0200 Subject: Add fff and other nice things such as macros --- fnl/plugins/lsp/diagnostics.fnl | 2 +- fnl/plugins/lsp/keymaps.fnl | 60 ++++++++++--------------------------- fnl/plugins/lsp/lspconfig.fnl | 25 ---------------- fnl/plugins/lsp/mason-lspconfig.fnl | 7 +---- fnl/plugins/lsp/mason.fnl | 14 --------- fnl/plugins/lsp/servers.fnl | 6 +--- 6 files changed, 19 insertions(+), 95 deletions(-) delete mode 100644 fnl/plugins/lsp/lspconfig.fnl delete mode 100644 fnl/plugins/lsp/mason.fnl (limited to 'fnl/plugins/lsp') diff --git a/fnl/plugins/lsp/diagnostics.fnl b/fnl/plugins/lsp/diagnostics.fnl index b4aefa6..b8bf5cc 100644 --- a/fnl/plugins/lsp/diagnostics.fnl +++ b/fnl/plugins/lsp/diagnostics.fnl @@ -15,7 +15,7 @@ :float {:focusable false :style :minimal :border :single - :source :always + :source true :header "" :prefix ""}}) diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl index f312581..3477f0a 100644 --- a/fnl/plugins/lsp/keymaps.fnl +++ b/fnl/plugins/lsp/keymaps.fnl @@ -1,50 +1,22 @@ ;; Key mappings for lsp. -(local mappings - [[:n :gD "lua vim.lsp.buf.declaration()" {:desc :Declaration}] - [:n - :gd - "Telescope lsp_definitions theme=get_dropdown" - {:desc :Definition}] - [:n - :gI - "Telescope lsp_implementations theme=get_dropdown" - {:desc :Implementation}] - [:n - :gr - "Telescope lsp_references theme=get_dropdown" - {:desc :References}] - [:n - :gl - "lua vim.diagnostic.open_float()" - {:desc :Diagnostics}] - [:n - :gj - "Telescope diagnostics theme=get_dropdown" - {:desc "Telescope Diagnostics"}] - [:n - :gw - "Telescope lsp_dynamic_workspace_symbols theme=get_dropdown" - {:desc "Workspace Symbols"}] - [:n - :gE - "Telescope lsp_type_definitions theme=get_dropdown" - {:desc "Type Definitions"}] - [:n :gm "lua vim.lsp.buf.signature_help()" {:desc :Signature}] - [:n - :gM - "Telescope lsp_document_symbols theme=get_dropdown" - {:desc "Document Symbols"}] - [:n :gh "lua vim.lsp.buf.code_action()" {:desc "Code Action"}] - [:n :gb "lua vim.lsp.codelens.run()" {:desc "Code Lens"}] - [:n :K "lua vim.lsp.buf.hover()" {:desc "Hover documentation"}] - [:n :li :LspInfo {:desc "Lsp Info"}]]) +(import-macros {: keymaps} :macros) (λ on-attach [buffer] - (let [opts {:noremap true :silent true : buffer}] - (each [_ mapping (ipairs mappings)] - (match mapping - [mode key cmd desc] - (vim.keymap.set mode key cmd (vim.tbl_extend :force opts desc)))))) + (keymaps + [:n :gD "lua vim.lsp.buf.declaration()" {:desc :Declaration :buffer buffer}] + [:n :gd "Telescope lsp_definitions theme=get_dropdown" {:desc :Definition :buffer buffer}] + [:n :gI "Telescope lsp_implementations theme=get_dropdown" {:desc :Implementation :buffer buffer}] + [:n :gr "Telescope lsp_references theme=get_dropdown" {:desc :References :buffer buffer}] + [:n :gl "lua vim.diagnostic.open_float()" {:desc :Diagnostics :buffer buffer}] + [:n :gj "Telescope diagnostics theme=get_dropdown" {:desc "Telescope Diagnostics" :buffer buffer}] + [:n :gw "Telescope lsp_dynamic_workspace_symbols theme=get_dropdown" {:desc "Workspace Symbols" :buffer buffer}] + [:n :gE "Telescope lsp_type_definitions theme=get_dropdown" {:desc "Type Definitions" :buffer buffer}] + [:n :gm "lua vim.lsp.buf.signature_help()" {:desc :Signature :buffer buffer}] + [:n :gM "Telescope lsp_document_symbols theme=get_dropdown" {:desc "Document Symbols" :buffer buffer}] + [:n :gh "lua vim.lsp.buf.code_action()" {:desc "Code Action" :buffer buffer}] + [:n :gb "lua vim.lsp.codelens.run()" {:desc "Code Lens" :buffer buffer}] + [:n :K "lua vim.lsp.buf.hover()" {:desc "Hover documentation" :buffer buffer}] + [:n :li :LspInfo {:desc "Lsp Info" :buffer buffer}])) {: on-attach} diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl deleted file mode 100644 index 192954c..0000000 --- a/fnl/plugins/lsp/lspconfig.fnl +++ /dev/null @@ -1,25 +0,0 @@ -;; Configuration for lsp clients. - -(λ on-attach [] - (vim.api.nvim_create_autocmd :LspAttach - {:callback (λ [args] - (let [{: on-attach} (require :plugins.lsp.keymaps) - buffer (. args :buf)] - (on-attach buffer)))})) - -(λ config [] - (on-attach) - (let [diagnostics (require :plugins.lsp.diagnostics) - mason-lspconfig (require :plugins.lsp.mason-lspconfig) - ui (require :lspconfig.ui.windows)] - (set ui.default_options.border :single) - (diagnostics.setup) - (mason-lspconfig.setup))) - -{1 :neovim/nvim-lspconfig - :event :BufNew - :dependencies [:mason.nvim - :williamboman/mason-lspconfig.nvim - :b0o/schemastore.nvim - :saghen/blink.cmp] - : config} diff --git a/fnl/plugins/lsp/mason-lspconfig.fnl b/fnl/plugins/lsp/mason-lspconfig.fnl index 48ea0b5..36b98c2 100644 --- a/fnl/plugins/lsp/mason-lspconfig.fnl +++ b/fnl/plugins/lsp/mason-lspconfig.fnl @@ -1,10 +1,6 @@ -;; A bridge plugin between mason and lspconfig, handles installation of lsp and +;; A bridge plugin between mason and lspconfig, handles installation of lsp and ;; setup hooks for client configurations. -(local textDocument-handlers - {:textDocument/hover (vim.lsp.with vim.lsp.handlers.hover) - :textDocument/signatureHelp (vim.lsp.with vim.lsp.handlers.signature_help)}) - (λ capabilities [] (let [blink-cmp (require :blink.cmp)] (blink-cmp.get_lsp_capabilities))) @@ -15,7 +11,6 @@ (let [lspconfig (. lspconfigs server) server-config (or (. servers server) {})] (tset server-config :capabilities (capabilities)) - (tset server-config :handlers textDocument-handlers) (lspconfig.setup server-config)))) (λ setup [] diff --git a/fnl/plugins/lsp/mason.fnl b/fnl/plugins/lsp/mason.fnl deleted file mode 100644 index e9c59ea..0000000 --- a/fnl/plugins/lsp/mason.fnl +++ /dev/null @@ -1,14 +0,0 @@ -;; Mason manages external tooling, e.g. lsp, formatters, and linters. - -(local icons (require :settings.icons)) - -(local opts {:ui {:border :single - :icons {:package_installed (.. (. icons :checkmark) " ") - :package_pending (.. (. icons :arrow-right) " ") - :package_uninstalled (.. (. icons :close) " ")}} - :max_concurrent_installers 10}) - -{1 :williamboman/mason.nvim - :cmd :Mason - :keys [{1 :m 2 :Mason :desc :Mason}] - : opts} diff --git a/fnl/plugins/lsp/servers.fnl b/fnl/plugins/lsp/servers.fnl index 7d213a8..13c6c9e 100644 --- a/fnl/plugins/lsp/servers.fnl +++ b/fnl/plugins/lsp/servers.fnl @@ -10,11 +10,7 @@ :jsonls {:init_options {:providerFormatter false} :settings {:json {:schemas (let [schemastore (require :schemastore)] (schemastore.json.schemas)) - :validate {:enable true}}} - :setup {:commands {:Format [(λ [] - (vim.lsp.buf.range_formatting [] [0 0] - [(vim.fn.line "$" - 0)]))]}}} + :validate {:enable true}}}} :ocamllsp {} :rust_analyzer {:settings {:rust-analyzer {:lens {:enable true} :checkOnSave {:command :clippy}}}} -- cgit v1.2.3-70-g09d2