diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index fd328ac..8bbf708 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -1,6 +1,7 @@ local nvim_lsp = require('lspconfig') local protocol = require('vim.lsp.protocol') local signature = require('lsp_signature') +local ts_utils = require("nvim-lsp-ts-utils") -- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ function preview_location(location, context, before_context) @@ -114,6 +115,40 @@ local on_attach = function(client, bufnr) '璉'; -- operator ' '; -- type parameter } + + if client.name == 'tsserver' then + ts_utils.setup { + debug = false, + disable_commands = false, + enable_import_on_completion = false, + import_on_completion_timeout = 5000, + + 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, + + 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, + + update_imports_on_move = false, + require_confirmation_on_move = false, + } + + ts_utils.setup_client(client) + + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'go', ':TSLspOrganize', { silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gf', ':TSLspFixCurrent', { silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gI', ':TSLspImportAll', { silent = true }) + end end function set_snippet_capabilities() diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 2db2a60..ae03a45 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -113,7 +113,8 @@ local init = function () -- LSP use { 'neovim/nvim-lspconfig', - 'ray-x/lsp_signature.nvim' + 'ray-x/lsp_signature.nvim', + 'jose-elias-alvarez/nvim-lsp-ts-utils' } -- Language support & syntax highlighting -- Coq