setup: formatters, linters, tree-sitters
This commit is contained in:
parent
721ef79eda
commit
1c8bed24cd
|
|
@ -7,3 +7,52 @@ vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = false
|
||||||
|
|
||||||
|
-- Configs for Programming Languages
|
||||||
|
-- like LSPs, Tree-sitters, Linters, Fromatters, Debuggers, etc.
|
||||||
|
Langs = {
|
||||||
|
treesitter = {
|
||||||
|
'bash',
|
||||||
|
'c',
|
||||||
|
'c_sharp',
|
||||||
|
'css',
|
||||||
|
'diff',
|
||||||
|
'go',
|
||||||
|
'html',
|
||||||
|
'lua',
|
||||||
|
'luadoc',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
|
'php',
|
||||||
|
'python',
|
||||||
|
'query',
|
||||||
|
'vim',
|
||||||
|
'vimdoc',
|
||||||
|
'zig',
|
||||||
|
},
|
||||||
|
|
||||||
|
linter = {
|
||||||
|
markdown = { 'mado' }, -- or rumdl
|
||||||
|
python = { 'ruff' },
|
||||||
|
},
|
||||||
|
|
||||||
|
fmt = {
|
||||||
|
lua = { 'stylua' },
|
||||||
|
sh = { 'shfmt' },
|
||||||
|
bash = { 'shfmt' },
|
||||||
|
python = { 'ruff_format' },
|
||||||
|
blade = { 'blade-formatter' },
|
||||||
|
markdown = { 'mdformat' },
|
||||||
|
},
|
||||||
|
|
||||||
|
fmt_cmd = {
|
||||||
|
shfmt = {
|
||||||
|
prepend_args = { '-i', '4' },
|
||||||
|
-- The base args are { "-filename", "$FILENAME" } so the final args will be
|
||||||
|
-- { "-filename", "$FILENAME", "-i", "2" }
|
||||||
|
},
|
||||||
|
['blade-formatter'] = {
|
||||||
|
prepend_args = { '-i', '2' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ return {
|
||||||
---@module 'conform'
|
---@module 'conform'
|
||||||
---@type conform.setupOpts
|
---@type conform.setupOpts
|
||||||
opts = {
|
opts = {
|
||||||
notify_on_error = false,
|
notify_on_error = true,
|
||||||
format_on_save = function(bufnr)
|
format_on_save = function(bufnr)
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||||
-- have a well standardized coding style. You can add additional
|
-- have a well standardized coding style. You can add additional
|
||||||
|
|
@ -31,13 +31,12 @@ return {
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
formatters_by_ft = {
|
formatters_by_ft = Langs.fmt,
|
||||||
lua = { 'stylua' },
|
|
||||||
-- Conform can also run multiple formatters sequentially
|
-- Conform can also run multiple formatters sequentially
|
||||||
-- python = { "isort", "black" },
|
-- python = { "isort", "black" },
|
||||||
--
|
--
|
||||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||||
},
|
formatters = Langs.fmt_cmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ return {
|
||||||
event = { 'BufReadPre', 'BufNewFile' },
|
event = { 'BufReadPre', 'BufNewFile' },
|
||||||
config = function()
|
config = function()
|
||||||
local lint = require 'lint'
|
local lint = require 'lint'
|
||||||
lint.linters_by_ft = {
|
lint.linters_by_ft = Langs.linter
|
||||||
markdown = { 'markdownlint' },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- To allow other plugins to add linters to require('lint').linters_by_ft,
|
-- To allow other plugins to add linters to require('lint').linters_by_ft,
|
||||||
-- instead set linters_by_ft like this:
|
-- instead set linters_by_ft like this:
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,7 @@ return {
|
||||||
branch = 'main',
|
branch = 'main',
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
|
||||||
config = function()
|
config = function()
|
||||||
local parsers = {
|
require('nvim-treesitter').install(Langs.treesitter)
|
||||||
'bash',
|
|
||||||
'c',
|
|
||||||
'diff',
|
|
||||||
'html',
|
|
||||||
'lua',
|
|
||||||
'luadoc',
|
|
||||||
'markdown',
|
|
||||||
'markdown_inline',
|
|
||||||
'query',
|
|
||||||
'vim',
|
|
||||||
'vimdoc',
|
|
||||||
}
|
|
||||||
require('nvim-treesitter').install(parsers)
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local buf, filetype = args.buf, args.match
|
local buf, filetype = args.buf, args.match
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue