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
|
||||
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'
|
||||
---@type conform.setupOpts
|
||||
opts = {
|
||||
notify_on_error = false,
|
||||
notify_on_error = true,
|
||||
format_on_save = function(bufnr)
|
||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||
-- have a well standardized coding style. You can add additional
|
||||
|
|
@ -31,13 +31,12 @@ return {
|
|||
}
|
||||
end
|
||||
end,
|
||||
formatters_by_ft = {
|
||||
lua = { 'stylua' },
|
||||
-- Conform can also run multiple formatters sequentially
|
||||
-- python = { "isort", "black" },
|
||||
--
|
||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
},
|
||||
formatters_by_ft = Langs.fmt,
|
||||
-- Conform can also run multiple formatters sequentially
|
||||
-- python = { "isort", "black" },
|
||||
--
|
||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
formatters = Langs.fmt_cmd,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ return {
|
|||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
config = function()
|
||||
local lint = require 'lint'
|
||||
lint.linters_by_ft = {
|
||||
markdown = { 'markdownlint' },
|
||||
}
|
||||
lint.linters_by_ft = Langs.linter
|
||||
|
||||
-- To allow other plugins to add linters to require('lint').linters_by_ft,
|
||||
-- instead set linters_by_ft like this:
|
||||
|
|
|
|||
|
|
@ -6,20 +6,7 @@ return {
|
|||
branch = 'main',
|
||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
|
||||
config = function()
|
||||
local parsers = {
|
||||
'bash',
|
||||
'c',
|
||||
'diff',
|
||||
'html',
|
||||
'lua',
|
||||
'luadoc',
|
||||
'markdown',
|
||||
'markdown_inline',
|
||||
'query',
|
||||
'vim',
|
||||
'vimdoc',
|
||||
}
|
||||
require('nvim-treesitter').install(parsers)
|
||||
require('nvim-treesitter').install(Langs.treesitter)
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
callback = function(args)
|
||||
local buf, filetype = args.buf, args.match
|
||||
|
|
|
|||
Loading…
Reference in New Issue