Skip to content

Commit

Permalink
feat(no-null-ls)!: Remove null-ls, replace with conform and nvim-lint
Browse files Browse the repository at this point in the history
BREAKING CHANGE: conform.nvim and nvim-lint introduced again after v1.0.0
  • Loading branch information
daUnknownCoder committed Mar 1, 2024
1 parent 1ed1e46 commit 5cbae70
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 63 deletions.
54 changes: 54 additions & 0 deletions lua/NeutronVim/plugins/LSP/formatting.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
lazy = true,
keys = {
{
"<leader>mf",
"<cmd>lua require('conform').format({lsp_fallback = true,async = false, timeout_ms = 500})<CR>",
mode = { "n", "v" },
desc = "Format",
},
},

config = function()
local conform_status_ok, conform = pcall(require, "conform")
if not conform_status_ok then
print("conform not found!")
end
conform.setup({
formatters_by_ft = {
javascript = { "prettierd" },
javascriptreact = { "prettierd" },
typescript = { "prettierd" },
typescriptreact = { "prettierd" },
json = { "prettierd" },
yaml = { "prettierd" },
markdown = { "prettierd" },
html = { "prettierd" },
css = { "prettierd" },
svelte = { "prettierd" },
lua = { "stylua" },
python = function(bufnr)
if require("conform").get_formatter_info("ruff_format", bufnr).available then
return { "ruff_format" }
else
return { "isort", "black" }
end
end,
rust = { "rustfmt" },
cpp = { "clang-format" },
c = { "clang-format" },
cmake = { "cmake_format" },
["*"] = { "codespell" },
fish = { "fish_indent" },
sh = { "shfmt" },
bash = { "shfmt" },
},
format_on_save = {
lsp_fallback = true,
async = true,
},
})
end,
}
29 changes: 29 additions & 0 deletions lua/NeutronVim/plugins/LSP/linting.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
return {
"daUnknownCoder/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
lazy = true,
keys = {
{ "<leader>mt", "<cmd>lua require('lint').try_lint()<cr>", desc = "Lint" },
},
config = function()
local linter_status_ok, lint = pcall(require, "lint")
if not linter_status_ok then
print("nvim-lint not found!")
end
lint.linters_by_ft = {
javascript = { "eslint_d" },
javascriptreact = { "eslint_d" },
typescript = { "eslint_d" },
typescriptreact = { "eslint_d" },
lua = { "luacheck" },
python = { "pylint" },
}
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,
})
end,
}
38 changes: 21 additions & 17 deletions lua/NeutronVim/plugins/LSP/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ return {
lazy = true,
dependencies = {
{ "williamboman/mason-lspconfig.nvim", cmd = { "LspInstall", "LspUninstall" } },
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
},
opts = {
ensure_installed = {
"black",
"isort",
"flake8",
"ruff",
"eslint_d",
"luacheck",
"prettierd",
"stylua",
},
ensure_installed = {},
},
config = function()
local icons_ok, icons = pcall(require, "NeutronVim.core.icons")
Expand All @@ -30,11 +22,10 @@ return {
if not mason_lspconfig_status_ok then
print("mason-lspconfig not found!")
end
local mason_null_ls_status_ok, mason_null_ls = pcall(require, "mason-null-ls")
if not mason_null_ls_status_ok then
print("mason-null-ls not found!")
local mason_tool_installer_status_ok, mason_tool_installer = pcall(require, "mason-tool-installer")
if not mason_tool_installer_status_ok then
print("mason-tool-installer not found!")
end

mason.setup({
ui = {
icons = {
Expand All @@ -52,19 +43,32 @@ return {
"lua_ls",
"pyright",
"marksman",
"eslint",
"clangd",
"cmake",
"bashls",
},
automatic_installation = true,
})
mason_null_ls.setup({
mason_tool_installer.setup({
ensure_installed = {
"prettierd",
"eslint_d",
"stylua",
"black",
"isort",
"ruff",
"eslint_d",
"pylint",
"luacheck",
"ruff",
"rustfmt",
"clang-format",
"cmakelang",
"codespell",
"shfmt",
},
auto_update = true,
run_on_start = true,
start_delay = 5000,
})
end,
}
46 changes: 0 additions & 46 deletions lua/NeutronVim/plugins/LSP/none-ls.lua

This file was deleted.

17 changes: 17 additions & 0 deletions lua/NeutronVim/plugins/UI/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ return {
symbols = { modified = " " .. icons.ui.Pencil, readonly = " " .. icons.ui.Lock, unnamed = " [None] " },
path = 0,
},
{
function()
local lint_progress = function()
local linters = require("lint").get_running()
if #linters == 0 then
return "󰦕 Linting completed"
end
return "󱉶 Linting with '" .. table.concat(linters, ", ") .. "' in progress"
end
return lint_progress()
end,
},
{
function()
return "%="
Expand Down Expand Up @@ -73,6 +85,11 @@ return {
},
},
lualine_x = {
{
function()
return "%="
end,
},
{
"diff",
symbols = {
Expand Down

0 comments on commit 5cbae70

Please sign in to comment.