nvim: add null-ls and enable tree-sitter again
Prithu Goswami pg@prithu.dev
Tue, 13 Sep 2022 11:56:15 +0530
3 files changed,
37 insertions(+),
20 deletions(-)
M
config/nvim/init.lua
→
config/nvim/init.lua
@@ -81,28 +81,44 @@ -- the default case_mode is "smart_case"
} } } + require('telescope').load_extension('fzf') --- require'nvim-treesitter.configs'.setup { --- ensure_installed = { "python", "hcl", "json", "go", "lua", "javascript", "typescript", "html", "css", "c", "cpp", "rust" }, --- sync_install = false, --- auto_install = true, --- -- ignore_install = { "javascript" }, --- highlight = { --- enable = true, --- -- disable = { "c", "rust" }, +require'nvim-treesitter.configs'.setup { + ensure_installed = { "python", "hcl", "json", "go", "lua", "javascript", "typescript", "html", "css", "c", "cpp", "rust" }, + sync_install = false, + auto_install = true, + -- ignore_install = { "javascript" }, + highlight = { + enable = true, + -- disable = { "c", "rust" }, --- -- Setting this to true will run `:h syntax` and tree-sitter at the same time. --- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). --- -- Using this option may slow down your editor, and you may see some duplicate highlights. --- -- Instead of true it can also be a list of languages --- additional_vim_regex_highlighting = true, --- }, --- indent = { --- enable = false, --- disable = {"hcl", "python"} --- } --- } + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = true, + }, + indent = { + enable = false, + disable = {"hcl", "python"} + } +} + +local null_ls = require("null-ls") + +null_ls.setup({ + debug = false, + sources = { + -- (java|type)script + null_ls.builtins.formatting.prettier, + -- python + null_ls.builtins.formatting.black.with({extra_args={"--fast"}}), + null_ls.builtins.formatting.isort, + null_ls.builtins.diagnostics.flake8, + null_ls.builtins.diagnostics.mypy, + } +}) -- TODO move to seperate autocmd file vim.cmd ([[
M
config/nvim/lua/lsp/init.lua
→
config/nvim/lua/lsp/init.lua
@@ -71,7 +71,7 @@ vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts) + vim.keymap.set('n', '<leader>]', vim.lsp.buf.formatting, bufopts) end
M
config/nvim/lua/plugins.lua
→
config/nvim/lua/plugins.lua
@@ -18,6 +18,7 @@ use 'chriskempson/base16-vim'
-- lsp use 'neovim/nvim-lspconfig' + use 'jose-elias-alvarez/null-ls.nvim' -- completion use 'hrsh7th/nvim-cmp'