Browse Source

Remove null ls and replace with confirm.nvim and nvim-lint

master
Tovi Jaeschke-Rogers 12 months ago
parent
commit
c82793b1c7
5 changed files with 101 additions and 72 deletions
  1. +3
    -2
      .config/nvim/lazy-lock.json
  2. +44
    -0
      .config/nvim/lua/tovi/plugins/formatting.lua
  3. +38
    -0
      .config/nvim/lua/tovi/plugins/linting.lua
  4. +16
    -14
      .config/nvim/lua/tovi/plugins/lsp/mason.lua
  5. +0
    -56
      .config/nvim/lua/tovi/plugins/lsp/null-ls.lua

+ 3
- 2
.config/nvim/lazy-lock.json View File

@ -6,6 +6,7 @@
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "ca3dfba94600aa62bfc88ae37cbd4f17eaea2553" },
"copilot.vim": { "branch": "release", "commit": "309b3c803d1862d5e84c7c9c5749ae04010123b8" },
"dart-vim-plugin": { "branch": "master", "commit": "928302ec931caf0dcf21835cca284ccd2b192f7b" },
"dressing.nvim": { "branch": "master", "commit": "fe3071330a0720ce3695ac915820c8134b22d1b0" },
@ -21,16 +22,16 @@
"lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "6eb8cae80f2e4322ec82cd9f8fa423f6d1eb02c3" },
"mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "e4f34741daa9cf95de68a603d3e7a6844a69fdf0" },
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
"minintro.nvim": { "branch": "master", "commit": "6bbb922a5628f5bc746fa2e13dbf5f9b6049c6b1" },
"neotest": { "branch": "master", "commit": "901891484db3d46ce43d56871273dc7d40621356" },
"neotest-go": { "branch": "main", "commit": "1a15e1136db43775214a3e7a598f8930c29c94b7" },
"neotest-phpunit": { "branch": "main", "commit": "e2dfa3280d2a33495a3f710bc364d2cfd1f40c83" },
"nightfly": { "branch": "master", "commit": "06ad2689ebd251a71c6caeb9fb47e231773c9b47" },
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" },
"nvim-lint": { "branch": "master", "commit": "775ae0e5a451dd6c5d15de7a828ea72d2c54e8cf" },
"nvim-lsp-file-operations": { "branch": "master", "commit": "1e0ffa0acc92f88f9f2b68df47ccbe1917653a42" },
"nvim-lspconfig": { "branch": "master", "commit": "90a28fd7637b66e055af62387ecee06f7cbd3173" },
"nvim-tree.lua": { "branch": "master", "commit": "874ae6e9445a5eb5ba430e5fd10212450a261ad7" },


+ 44
- 0
.config/nvim/lua/tovi/plugins/formatting.lua View File

@ -0,0 +1,44 @@
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
lua = { "stylua" },
go = { "goimports", "gofmt" },
javascript = { "prettier" },
typescript = { "prettier" },
vue = { "prettier" },
css = { "prettier" },
html = { "prettier" },
markdown = { "prettier" },
json = { "fixjson" },
rust = { "rustfmt" },
shell = { "shfmt", "shellcheck" },
python = { "isort", "black" },
["*"] = { "codespell" },
["_"] = { "trim_whitespace" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
format_after_save = {
lsp_fallback = true,
},
log_level = vim.log.levels.ERROR,
notify_on_error = true,
})
vim.keymap.set({ "n", "v" }, "<leader>ff", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
end)
end,
}

+ 38
- 0
.config/nvim/lua/tovi/plugins/linting.lua View File

@ -0,0 +1,38 @@
return {
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
lint.linters_by_ft = {
javascript = { "eslint_d" },
typescript = { "eslint_d" },
vue = { "eslint_d" },
json = { "jsonlint" },
markdown = { "markdownlint" },
php = { "phpcs" },
golang = { "gospell", "golangci-lint" },
python = { "pylint" },
dockerfile = { "hadolint" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", {
clear = true,
})
vim.api.nvim_create_autocmd({
"BufEnter",
"BufWritePost",
"InsertLeave",
}, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>ll", function()
lint.try_lint()
end)
end,
}

+ 16
- 14
.config/nvim/lua/tovi/plugins/lsp/mason.lua View File

@ -2,7 +2,7 @@ return {
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
"jayp0521/mason-null-ls.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
},
config = function()
-- import mason
@ -11,8 +11,7 @@ return {
-- import mason-lspconfig
local mason_lspconfig = require("mason-lspconfig")
-- import mason-null-ls
local mason_null_ls = require("mason-null-ls")
local mason_tool_installer = require("mason-tool-installer")
-- enable mason and configure icons
mason.setup({
@ -34,25 +33,28 @@ return {
"tailwindcss",
"svelte",
"lua_ls",
"graphql",
"emmet_ls",
"prismals",
"pyright",
"intelephense",
"gopls",
"gopls",
},
-- auto-install configured servers (with lspconfig)
automatic_installation = true, -- not the same as ensure_installed
automatic_installation = true,
})
mason_null_ls.setup({
-- list of formatters & linters for mason to install
mason_tool_installer.setup({
ensure_installed = {
"prettier", -- ts/js formatter
"stylua", -- lua formatter
"eslint_d", -- ts/js linter
"prettier",
"eslint_d",
"jsonlint",
"markdownlint",
"phpcs",
"gospel",
"golangci-lint",
"pylint",
"hadolint",
"gofumpt",
"goimports",
},
-- auto-install configured servers (with lspconfig)
automatic_installation = true,
})
end,


+ 0
- 56
.config/nvim/lua/tovi/plugins/lsp/null-ls.lua View File

@ -1,56 +0,0 @@
return {
"jose-elias-alvarez/null-ls.nvim", -- configure formatters & linters
event = { "BufReadPre", "BufNewFile" },
config = function()
-- import null-ls plugin
local null_ls = require("null-ls")
local null_ls_utils = require("null-ls.utils")
-- for conciseness
local formatting = null_ls.builtins.formatting -- to setup formatters
local diagnostics = null_ls.builtins.diagnostics -- to setup linters
-- to setup format on save
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-- configure null_ls
null_ls.setup({
-- add package.json as identifier for root (for typescript monorepos)
root_dir = null_ls_utils.root_pattern(".null-ls-root", "Makefile", ".git", "package.json"),
-- setup formatters & linters
sources = {
-- to disable file types use
-- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs)
formatting.prettier.with({
extra_filetypes = { "svelte" },
}), -- js/ts formatter
formatting.stylua, -- lua formatter
diagnostics.eslint_d.with({ -- js/ts linter
condition = function(utils)
return utils.root_has_file({ ".eslintrc.js", ".eslintrc.cjs" }) -- only enable if root has .eslintrc.js or .eslintrc.cjs
end,
}),
},
-- configure format on save
-- on_attach = function(current_client, bufnr)
-- if current_client.supports_method("textDocument/formatting") then
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- group = augroup,
-- buffer = bufnr,
-- callback = function()
-- vim.lsp.buf.format({
-- filter = function(client)
-- -- only use null-ls for formatting instead of lsp server
-- return client.name == "null-ls"
-- end,
-- bufnr = bufnr,
-- })
-- end,
-- })
-- end
-- end,
})
end,
}

Loading…
Cancel
Save