diff options
Diffstat (limited to '.config/nvim')
| -rw-r--r-- | .config/nvim/lua/custom/plugins/conform.lua | 38 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/plugins/none-ls.lua | 12 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/plugins/nvim-lint.lua | 20 |
3 files changed, 58 insertions, 12 deletions
diff --git a/.config/nvim/lua/custom/plugins/conform.lua b/.config/nvim/lua/custom/plugins/conform.lua new file mode 100644 index 0000000..759f5ba --- /dev/null +++ b/.config/nvim/lua/custom/plugins/conform.lua @@ -0,0 +1,38 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { '<leader>ft', '<cmd>FormatToggle<cr>', desc = '[F]ormat [T]oggle Globally' }, + { '<leader>fT', '<cmd>FormatToggle!<cr>', desc = '[F]ormat [T]oggle Locally' }, + { '<leader>ff', '<cmd>Format<cr>', desc = '[F]ormat [F]ile' }, + { '<leader>f', '<cmd>Format<cr><esc>', desc = '[F]ormat', mode = 'v' }, + }, + ---@module "conform" + ---@type conform.setupOpts + opts = { + formatters_by_ft = { + ['lua'] = { 'stylua' }, + ['c'] = { 'clang-format' }, + ['python'] = { 'isort', 'black' }, + ['rust'] = { 'rustfmt' }, + ['go'] = { 'gofumpt' }, + ['markdown'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['yaml'] = { 'prettierd' }, + ['json'] = { 'jq' }, + ['html'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['css'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['javascript'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['typescript'] = { 'prettierd', 'prettier', stop_after_first = true }, + }, + format_on_save = function(bufnr) + -- Disable with a global or buffer local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, + notify_on_error = true, + lsp_fallback = true, + }, +} diff --git a/.config/nvim/lua/custom/plugins/none-ls.lua b/.config/nvim/lua/custom/plugins/none-ls.lua deleted file mode 100644 index 763172f..0000000 --- a/.config/nvim/lua/custom/plugins/none-ls.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'nvimtools/none-ls.nvim', - event = 'LspAttach', - config = function() - local null_ls = require('null-ls') - null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - }, - }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/nvim-lint.lua b/.config/nvim/lua/custom/plugins/nvim-lint.lua new file mode 100644 index 0000000..0ff280c --- /dev/null +++ b/.config/nvim/lua/custom/plugins/nvim-lint.lua @@ -0,0 +1,20 @@ +return { + 'mfussenegger/nvim-lint', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + local lint = require('lint') + lint.linters_by_ft = { + go = { 'golangci-lint' }, + python = { 'flake8' }, + json = { 'jsonlint' }, + bash = { 'shellcheck' }, + } + + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave', 'TextChanged', 'TextChangedI' }, { + group = vim.api.nvim_create_augroup('nvim-lint', { clear = true }), + callback = function() + require('lint').try_lint() + end, + }) + end, +} |
