add linter and formatting support
This commit is contained in:
parent
400e7eeb5e
commit
2e76dd1cab
6 changed files with 51 additions and 40 deletions
|
|
@ -1,2 +1 @@
|
||||||
require("aleidk.IDE.completion")
|
require("aleidk.IDE.completion")
|
||||||
require("aleidk.IDE.null-ls")
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
-- Linter and formatter configuration
|
|
||||||
|
|
||||||
require("mason-null-ls").setup({
|
|
||||||
handlers = {}, -- this make mason-null-ls to auto setup handlers
|
|
||||||
ensure_installed = {
|
|
||||||
"blade_formatter",
|
|
||||||
"blue",
|
|
||||||
"eslint_d",
|
|
||||||
"fixjson",
|
|
||||||
"gitlint",
|
|
||||||
"intelephense",
|
|
||||||
"markdownlint",
|
|
||||||
"php-cs-fixer",
|
|
||||||
"prettierd",
|
|
||||||
"shellcheck",
|
|
||||||
"shfmt",
|
|
||||||
"sql-formatter",
|
|
||||||
"stylua",
|
|
||||||
"yamlint",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local null_ls = require("null-ls.builtins")
|
|
||||||
|
|
||||||
require("null-ls").setup({
|
|
||||||
sources = {
|
|
||||||
null_ls.formatting.prettierd.with({
|
|
||||||
disabled_filetypes = { "markdown" },
|
|
||||||
}),
|
|
||||||
|
|
||||||
null_ls.formatting.phpcsfixer.with({
|
|
||||||
extra_args = {
|
|
||||||
"--config",
|
|
||||||
"$HOME/.config/php-cs-fixer-conf.php",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
22
config/nvim/lua/aleidk/plugins/formatter.lua
Normal file
22
config/nvim/lua/aleidk/plugins/formatter.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
return {
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
opts = {
|
||||||
|
formatters_by_ft = {
|
||||||
|
-- Conform will run multiple formatters sequentially
|
||||||
|
lua = { "stylua" },
|
||||||
|
python = { "black" },
|
||||||
|
-- Use a sub-list to run only the first available formatter
|
||||||
|
javascript = { { "prettierd", "prettier" } },
|
||||||
|
typescript = { { "prettierd", "prettier" } },
|
||||||
|
javascriptreact = { { "prettierd", "prettier" } },
|
||||||
|
typescriptreact = { { "prettierd", "prettier" } },
|
||||||
|
-- Use the "_" filetype to run formatters on filetypes that don't
|
||||||
|
-- have other formatters configured.
|
||||||
|
["_"] = { "trim_whitespace" },
|
||||||
|
},
|
||||||
|
format_on_save = {
|
||||||
|
timeout_ms = 500,
|
||||||
|
lsp_fallback = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
19
config/nvim/lua/aleidk/plugins/linters.lua
Normal file
19
config/nvim/lua/aleidk/plugins/linters.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
return {
|
||||||
|
"mfussenegger/nvim-lint",
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("lint").linters_by_ft = {
|
||||||
|
javascript = { "eslint_d" },
|
||||||
|
typescript = { "eslint_d" },
|
||||||
|
javascriptreact = { "eslint_d" },
|
||||||
|
typescriptreact = { "eslint_d" },
|
||||||
|
-- astro = { "eslint_d" },
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
|
callback = function()
|
||||||
|
require("lint").try_lint()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
-- Automatically install LSPs to stdpath for neovim
|
||||||
{ "williamboman/mason.nvim", config = true },
|
{ "williamboman/mason.nvim" },
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
-- Useful status updates for LSP
|
||||||
|
|
|
||||||
9
config/nvim/lua/aleidk/plugins/mason.lua
Normal file
9
config/nvim/lua/aleidk/plugins/mason.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
opts = {
|
||||||
|
ensure_installed = {
|
||||||
|
"typescript-language-server",
|
||||||
|
"eslint_d",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue