Skip to content

Commit 5cbae70

Browse files
feat(no-null-ls)!: Remove null-ls, replace with conform and nvim-lint
BREAKING CHANGE: conform.nvim and nvim-lint introduced again after v1.0.0
1 parent 1ed1e46 commit 5cbae70

5 files changed

Lines changed: 121 additions & 63 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
return {
2+
"stevearc/conform.nvim",
3+
event = { "BufReadPre", "BufNewFile" },
4+
lazy = true,
5+
keys = {
6+
{
7+
"<leader>mf",
8+
"<cmd>lua require('conform').format({lsp_fallback = true,async = false, timeout_ms = 500})<CR>",
9+
mode = { "n", "v" },
10+
desc = "Format",
11+
},
12+
},
13+
14+
config = function()
15+
local conform_status_ok, conform = pcall(require, "conform")
16+
if not conform_status_ok then
17+
print("conform not found!")
18+
end
19+
conform.setup({
20+
formatters_by_ft = {
21+
javascript = { "prettierd" },
22+
javascriptreact = { "prettierd" },
23+
typescript = { "prettierd" },
24+
typescriptreact = { "prettierd" },
25+
json = { "prettierd" },
26+
yaml = { "prettierd" },
27+
markdown = { "prettierd" },
28+
html = { "prettierd" },
29+
css = { "prettierd" },
30+
svelte = { "prettierd" },
31+
lua = { "stylua" },
32+
python = function(bufnr)
33+
if require("conform").get_formatter_info("ruff_format", bufnr).available then
34+
return { "ruff_format" }
35+
else
36+
return { "isort", "black" }
37+
end
38+
end,
39+
rust = { "rustfmt" },
40+
cpp = { "clang-format" },
41+
c = { "clang-format" },
42+
cmake = { "cmake_format" },
43+
["*"] = { "codespell" },
44+
fish = { "fish_indent" },
45+
sh = { "shfmt" },
46+
bash = { "shfmt" },
47+
},
48+
format_on_save = {
49+
lsp_fallback = true,
50+
async = true,
51+
},
52+
})
53+
end,
54+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
return {
2+
"daUnknownCoder/nvim-lint",
3+
event = { "BufReadPre", "BufNewFile" },
4+
lazy = true,
5+
keys = {
6+
{ "<leader>mt", "<cmd>lua require('lint').try_lint()<cr>", desc = "Lint" },
7+
},
8+
config = function()
9+
local linter_status_ok, lint = pcall(require, "lint")
10+
if not linter_status_ok then
11+
print("nvim-lint not found!")
12+
end
13+
lint.linters_by_ft = {
14+
javascript = { "eslint_d" },
15+
javascriptreact = { "eslint_d" },
16+
typescript = { "eslint_d" },
17+
typescriptreact = { "eslint_d" },
18+
lua = { "luacheck" },
19+
python = { "pylint" },
20+
}
21+
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
22+
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
23+
group = lint_augroup,
24+
callback = function()
25+
lint.try_lint()
26+
end,
27+
})
28+
end,
29+
}

lua/NeutronVim/plugins/LSP/mason.lua

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,10 @@ return {
44
lazy = true,
55
dependencies = {
66
{ "williamboman/mason-lspconfig.nvim", cmd = { "LspInstall", "LspUninstall" } },
7+
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
78
},
89
opts = {
9-
ensure_installed = {
10-
"black",
11-
"isort",
12-
"flake8",
13-
"ruff",
14-
"eslint_d",
15-
"luacheck",
16-
"prettierd",
17-
"stylua",
18-
},
10+
ensure_installed = {},
1911
},
2012
config = function()
2113
local icons_ok, icons = pcall(require, "NeutronVim.core.icons")
@@ -30,11 +22,10 @@ return {
3022
if not mason_lspconfig_status_ok then
3123
print("mason-lspconfig not found!")
3224
end
33-
local mason_null_ls_status_ok, mason_null_ls = pcall(require, "mason-null-ls")
34-
if not mason_null_ls_status_ok then
35-
print("mason-null-ls not found!")
25+
local mason_tool_installer_status_ok, mason_tool_installer = pcall(require, "mason-tool-installer")
26+
if not mason_tool_installer_status_ok then
27+
print("mason-tool-installer not found!")
3628
end
37-
3829
mason.setup({
3930
ui = {
4031
icons = {
@@ -52,19 +43,32 @@ return {
5243
"lua_ls",
5344
"pyright",
5445
"marksman",
46+
"eslint",
47+
"clangd",
48+
"cmake",
49+
"bashls",
5550
},
5651
automatic_installation = true,
5752
})
58-
mason_null_ls.setup({
53+
mason_tool_installer.setup({
5954
ensure_installed = {
6055
"prettierd",
56+
"eslint_d",
6157
"stylua",
6258
"black",
6359
"isort",
64-
"ruff",
65-
"eslint_d",
60+
"pylint",
6661
"luacheck",
62+
"ruff",
63+
"rustfmt",
64+
"clang-format",
65+
"cmakelang",
66+
"codespell",
67+
"shfmt",
6768
},
69+
auto_update = true,
70+
run_on_start = true,
71+
start_delay = 5000,
6872
})
6973
end,
7074
}

lua/NeutronVim/plugins/LSP/none-ls.lua

Lines changed: 0 additions & 46 deletions
This file was deleted.

lua/NeutronVim/plugins/UI/lualine.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ return {
4040
symbols = { modified = " " .. icons.ui.Pencil, readonly = " " .. icons.ui.Lock, unnamed = " [None] " },
4141
path = 0,
4242
},
43+
{
44+
function()
45+
local lint_progress = function()
46+
local linters = require("lint").get_running()
47+
if #linters == 0 then
48+
return "󰦕 Linting completed"
49+
end
50+
return "󱉶 Linting with '" .. table.concat(linters, ", ") .. "' in progress"
51+
end
52+
return lint_progress()
53+
end,
54+
},
4355
{
4456
function()
4557
return "%="
@@ -73,6 +85,11 @@ return {
7385
},
7486
},
7587
lualine_x = {
88+
{
89+
function()
90+
return "%="
91+
end,
92+
},
7693
{
7794
"diff",
7895
symbols = {

0 commit comments

Comments
 (0)