nvim-config/lua/plugins/syntax.lua

68 lines
2.1 KiB
Lua

local lm = require('custom.language-manager')
local language_specs = {
{ ts = { 'yaml', 'toml', 'sql', 'diff', 'dockerfile', 'gitcommit', 'gitignore' } },
{ ts = { 'c', 'cpp', 'go', 'rust', 'python' } },
{ ft = 'markdown', ts = { 'markdown', 'markdown_inline' }, format = 'prettier' },
{ ft = 'bash', lsp = 'bash-language-server', lint = 'shellcheck', format = 'shfmt' },
{ ft = 'lua', lsp = 'lua-language-server', lint = 'luacheck', format = 'stylua' },
{ ft = { 'json', 'jsonc' }, lsp = 'json-lsp' },
{ ft = 'html', lsp = 'html-lsp' },
{ ft = 'css', lsp = { 'css-lsp', 'tailwindcss-language-server' } },
{
ft = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' },
ts = { 'javascript', 'typescript', 'tsx' },
lsp = { 'vtsls', 'eslint-lsp' },
format = { 'prettierd', 'prettier' },
},
}
local general = lm.generate_specs(language_specs)
return {
{ 'windwp/nvim-ts-autotag', config = true },
{ 'windwp/nvim-autopairs', event = 'InsertEnter', config = true },
{
'mason-org/mason.nvim',
config = function()
require('mason').setup()
lm.lsp.enable()
end,
},
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
main = 'nvim-treesitter.configs',
opts = {
highlight = { enable = true },
incremental_selection = { enable = true },
ensure_installed = general.ts_parsers,
},
},
{
'mfussenegger/nvim-lint',
event = { 'BufReadPre', 'BufNewFile' },
opts = { linters_by_ft = general.linters_by_ft },
config = function(_, opts)
local lint = require('lint')
lint.linters_by_ft = opts.linters_by_ft
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = vim.api.nvim_create_augroup('lint_autocmd', { clear = true }),
callback = function()
lint.try_lint()
end,
})
end,
},
{
'stevearc/conform.nvim',
event = { 'BufWritePre' },
opts = {
format_on_save = { timeout_ms = 500, lsp_format = 'fallback' },
default_format_opts = { stop_after_first = true },
formatters_by_ft = general.formatters_by_ft,
},
},
}