diff options
| author | Robert Günzler <r@gnzler.io> | 2023-03-21 12:41:30 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2023-03-21 12:41:30 +0100 |
| commit | 65f778c4d3d1c860a4f0003ecf980a38b0e008b3 (patch) | |
| tree | 34dfabbc417e82e67714dd911490fd9eeaa522c8 /.vim/lua | |
| parent | 8899aa36853c824a39511c5205bd9ab1245716fb (diff) | |
vim: improve null-ls configuration of beautifier
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
| -rw-r--r-- | .vim/lua/plugins.lua | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index e8eefc7..7028cda 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -791,61 +791,56 @@ local pluginspec = { { 'jose-elias-alvarez/null-ls.nvim', - ft = { 'sh', 'bash', 'lua', 'rust', 'c', 'cpp', 'css', 'scss', 'html', 'javascript' }, + ft = { + 'sh', + 'bash', + 'lua', + 'rust', + 'c', + 'cpp', + 'css', + 'scss', + 'html', + 'javascript', + 'markdown', + }, dependencies = { 'nvim-lua/plenary.nvim' }, config = function() local nls = require('null-ls') + local nls_h = require('null-ls.helpers') + + local beautifier = nls_h.make_builtin({ + name = 'beautifier', + method = nls.methods.FORMATTING, + generator_opts = { + args = { '--file', '-', '--editorconfig' }, + to_stdin = true, + }, + env = { + ['PATH'] = (vim.env.HOME .. '/.yarn/bin') .. ':' .. vim.env.PATH, + }, + factory = nls_h.formatter_factory, + }) + nls.setup({ - -- debug = true, + debug = true, + on_attach = require('internal.lsp').my_attach, sources = { nls.builtins.diagnostics.shellcheck, nls.builtins.formatting.shfmt, - nls.builtins.formatting.yapf, -- python + -- nls.builtins.formatting.yapf, -- python nls.builtins.formatting.clang_format, nls.builtins.formatting.rustfmt, nls.builtins.formatting.stylua, -- nls.builtins.formatting.gofumpt, -- nls.builtins.formatting.json_tool, - }, - on_attach = require('internal.lsp').my_attach, - }) - - local h = require('null-ls.helpers') + nls.builtins.formatting.mdformat, - nls.register({ - h.make_builtin({ - name = 'html-beautify', - filetypes = { 'html', 'gotmpl.html' }, - method = nls.methods.FORMATTING, - generator_opts = { - command = vim.env.HOME .. '/.yarn/bin/html-beautify', - args = { '--file', '-', '--editorconfig' }, - to_stdin = true, - }, - factory = h.formatter_factory, - }), - h.make_builtin({ - name = 'html-beautify', - filetypes = { 'html', 'gotmpl.html' }, - method = nls.methods.FORMATTING, - generator_opts = { - command = vim.env.HOME .. '/.yarn/bin/html-beautify', - args = { '--file', '-', '--editorconfig' }, - to_stdin = true, - }, - factory = h.formatter_factory, - }), - h.make_builtin({ - name = 'css-beautify', - filetypes = { 'css', 'scss' }, - method = nls.methods.FORMATTING, - generator_opts = { - command = vim.env.HOME .. '/.yarn/bin/css-beautify', - args = { '--file', '-', '--editorconfig' }, - to_stdin = true, - }, - factory = h.formatter_factory, - }), + -- custom sources + beautifier.with({ filetypes = { 'html', 'gotmpl.html' }, command = 'html-beautify' }), + beautifier.with({ filetypes = { 'css', 'scss' }, command = 'css-beautify' }), + beautifier.with({ filetypes = { 'javascript' }, command = 'js-beautify' }), + }, }) end, }, |