From b96571d104ab72d95c41ffc120afa260dd280934 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 4 Dec 2023 22:20:46 +0100 Subject: Replace null(none)-ls with conform and nvim-lint --- fnl/plugins/editor/conform.fnl | 34 +++++++++++++++++++++++++++++++ fnl/plugins/editor/lualine.fnl | 3 +-- fnl/plugins/editor/nvim-lint.fnl | 26 ++++++++++++++++++++++++ fnl/plugins/lsp/init.fnl | 4 +--- fnl/plugins/lsp/keymaps.fnl | 4 ---- fnl/plugins/lsp/null-ls.fnl | 43 ---------------------------------------- 6 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 fnl/plugins/editor/conform.fnl create mode 100644 fnl/plugins/editor/nvim-lint.fnl delete mode 100644 fnl/plugins/lsp/null-ls.fnl (limited to 'fnl/plugins') diff --git a/fnl/plugins/editor/conform.fnl b/fnl/plugins/editor/conform.fnl new file mode 100644 index 0000000..4f1b01a --- /dev/null +++ b/fnl/plugins/editor/conform.fnl @@ -0,0 +1,34 @@ +;; Formatting + +(fn init [] + (vim.keymap.set [:n :v] :e + (lambda [] + (let [conform (require :conform)] + (conform.format {:lsp_fallback true :async true}))) + {:desc :Format})) + +(fn config [] + (let [conform (require :conform)] + (conform.setup {:formatters {:fnlfmt {:command :fnlfmt + :args [:--fix :$FILENAME] + :stdin false}} + :formatters_by_ft {:* [:codespell + :trim_whitespace + :trim_newlines] + :css [:stylelint] + :fennel [:fnlfmt] + :haskell [:fourmolu] + :html [:djlint] + :json [:jq] + :lua [:stylua] + :markdown [:cbfmt] + :ocaml [:ocamlformat] + :org [:cbfmt] + :python [:ruff_format] + :rust [:rustfmt] + :sh [:shfmt :shellharden] + :sql [:pg_format :sqlfluff] + :toml [:taplo] + :yaml [:yamlfmt]}}))) + +{1 :stevearc/conform.nvim : init : config :event [:BufReadPost :BufNewFile]} diff --git a/fnl/plugins/editor/lualine.fnl b/fnl/plugins/editor/lualine.fnl index 06d7fde..a34e73e 100644 --- a/fnl/plugins/editor/lualine.fnl +++ b/fnl/plugins/editor/lualine.fnl @@ -18,8 +18,7 @@ (let [clients (vim.lsp.buf_get_clients) client_names []] (each [_ client (pairs clients)] - (if (not= client.name :null-ls) - (table.insert client_names client.name))) + (table.insert client_names client.name)) (if (> (length client_names) 0) (table.concat client_names ", ") ""))) diff --git a/fnl/plugins/editor/nvim-lint.fnl b/fnl/plugins/editor/nvim-lint.fnl new file mode 100644 index 0000000..bcec08b --- /dev/null +++ b/fnl/plugins/editor/nvim-lint.fnl @@ -0,0 +1,26 @@ +;; Linting + +(fn init [] + (let [lint-augroup (vim.api.nvim_create_augroup :lint {:clear true}) + lint (require :lint)] + (vim.api.nvim_create_autocmd [:BufEnter :BufWritePost :InsertLeave] + {:group lint-augroup + :callback (lambda [] + (lint.try_lint))}))) + +(fn config [] + (let [lint (require :lint)] + (set lint.linters_by_ft {:zsh [:zsh] + :* [:codespell :write_good] + :fennel [:fennel] + :yaml [:yamllint] + :python [:ruff] + :lua [:selene] + :commit [:commitlint] + :docker [:hadolint] + :haskell [:hlint] + :json [:jsonlint] + :sh [:shellcheck] + :sql [:sqlfluff]}))) + +{1 :mfussenegger/nvim-lint : init : config :event [:BufReadPost :BufNewFile]} diff --git a/fnl/plugins/lsp/init.fnl b/fnl/plugins/lsp/init.fnl index bef4141..f04ba86 100644 --- a/fnl/plugins/lsp/init.fnl +++ b/fnl/plugins/lsp/init.fnl @@ -1,5 +1,3 @@ ;; Lsp plugins. -[(require :plugins.lsp.lspconfig) - (require :plugins.lsp.mason) - (require :plugins.lsp.null-ls)] +[(require :plugins.lsp.lspconfig) (require :plugins.lsp.mason)] diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl index 6a3544a..d87b32c 100644 --- a/fnl/plugins/lsp/keymaps.fnl +++ b/fnl/plugins/lsp/keymaps.fnl @@ -20,10 +20,6 @@ :a "lua vim.lsp.buf.code_action()" {:desc "Code Action"}] - [:n - :e - "lua vim.lsp.buf.format { async = true }" - {:desc :Format}] [:v :e "lua vim.lsp.buf.format { async = true }" diff --git a/fnl/plugins/lsp/null-ls.fnl b/fnl/plugins/lsp/null-ls.fnl deleted file mode 100644 index ff98aee..0000000 --- a/fnl/plugins/lsp/null-ls.fnl +++ /dev/null @@ -1,43 +0,0 @@ -;; Adds LSP diagnostics and formatting. - -(local mason-opts {:ensure_installed nil - :automatic_installation true - :automatic_setup false}) - -(fn config [] - (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.ocamlformat - formatting.prettierd - formatting.ruff - formatting.rustfmt - formatting.shellharden - formatting.shfmt - formatting.sqlfluff - formatting.stylua - formatting.terraform_fmt]})) - (mason-null-ls.setup mason-opts))) - -{1 :nvimtools/none-ls.nvim - :dependencies [:mason.nvim - :jayp0521/mason-null-ls.nvim - :nvim-lua/plenary.nvim] - :event :BufReadPost - : config} -- cgit v1.2.3-70-g09d2