diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index f4e4ea4..6d5db2e 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -123,31 +123,37 @@ local on_attach = function(client, bufnr) } if client.name == 'tsserver' then - null_ls.setup {} + -- Disable tsserver formatting as we plan on formatting via null-ls + client.resolved_capabilities.document_formatting = false + ts_utils.setup { debug = false, disable_commands = false, enable_import_on_completion = false, - import_on_completion_timeout = 5000, + + import_all_timeout = 5000, + import_all_scan_buffers = 100, + import_all_select_source = false, + import_all_priorities = { + buffers = 4, -- loaded buffer names + buffer_content = 3, -- loaded buffer content + local_files = 2, -- git files or files with relative path markers + same_file = 1, -- add to existing import statement + }, eslint_enable_code_actions = true, eslint_bin = "eslint", - eslint_args = {"-f", "json", "--stdin", "--stdin-filename", "$FILENAME"}, eslint_enable_disable_comments = true, eslint_enable_diagnostics = true, - eslint_diagnostics_debounce = 250, + eslint_config_fallback = nil, enable_formatting = true, formatter = "prettier", - formatter_args = {"--stdin-filepath", "$FILENAME"}, - format_on_save = false, - no_save_after_format = false, - - complete_parens = true, - signature_help_in_parens = false, + formatter_config_fallback = nil, update_imports_on_move = false, require_confirmation_on_move = false, + watch_dir = nil, } ts_utils.setup_client(client) @@ -172,6 +178,12 @@ function set_snippet_capabilities() return capabilities end +-- This should be called only once, so cannot be in on_attach as earlier. +-- See https://github.com/jose-elias-alvarez/null-ls.nvim/issues/38 +-- Required by nvim-lsp-ts-utils to provide ESLint code actions, diagnostics +-- and formatting. +null_ls.setup {} + local servers = { 'hls', 'rust_analyzer', 'pylsp', 'tsserver' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {