This repository has been archived by the owner on Jul 17, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
[BUG] :TsLsImportCurrent and :TsLspImportAll do not work on library code #119
Labels
bug
Something isn't working
Comments
My config local lspconfig = require("lspconfig")
local null_ls = require("null-ls")
local buf_map = function(bufnr, mode, lhs, rhs, opts)
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts or {
silent = true,
})
end
local on_attach = function(client, bufnr)
vim.cmd("command! LspDef lua vim.lsp.buf.definition()")
vim.cmd("command! LspFormatting lua vim.lsp.buf.formatting()")
vim.cmd("command! LspCodeAction lua vim.lsp.buf.code_action()")
vim.cmd("command! LspHover lua vim.lsp.buf.hover()")
vim.cmd("command! LspRename lua vim.lsp.buf.rename()")
vim.cmd("command! LspRefs lua vim.lsp.buf.references()")
vim.cmd("command! LspTypeDef lua vim.lsp.buf.type_definition()")
vim.cmd("command! LspImplementation lua vim.lsp.buf.implementation()")
vim.cmd("command! LspDiagPrev lua vim.diagnostic.goto_prev()")
vim.cmd("command! LspDiagNext lua vim.diagnostic.goto_next()")
vim.cmd("command! LspDiagLine lua vim.diagnostic.open_float()")
vim.cmd("command! LspSignatureHelp lua vim.lsp.buf.signature_help()")
buf_map(bufnr, "n", "g2", ":LspRename<CR>")
buf_map(bufnr, "n", "gy", ":LspTypeDef<CR>")
buf_map(bufnr, "n", "[a", ":LspDiagPrev<CR>")
buf_map(bufnr, "n", "]a", ":LspDiagNext<CR>")
buf_map(bufnr, "n", "<Leader>a", ":LspDiagLine<CR>")
buf_map(bufnr, "i", "<C-x><C-x>", "<cmd> LspSignatureHelp<CR>")
if client.resolved_capabilities.document_formatting then
vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()")
end
end
lspconfig.tsserver.setup({
on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
local ts_utils = require("nvim-lsp-ts-utils")
ts_utils.setup({enable_import_on_completion = false, debug = true})
ts_utils.setup_client(client)
buf_map(bufnr, "n", "gs", ":TSLspOrganize<CR>")
buf_map(bufnr, "n", "go", ":TSLspRenameFile<CR>")
buf_map(bufnr, "n", "go", ":TSLspImportAll<CR>")
buf_map(bufnr, "n", "gi", ":TSLspImportCurrent<CR>")
on_attach(client, bufnr)
end,
})
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.eslint_d,
null_ls.builtins.code_actions.eslint_d,
null_ls.builtins.formatting.prettier,
},
on_attach = on_attach,
})
|
I can't really act on this given your reproduction instructions, since there's so many variables that could be affecting this (project structure, TypeScript / LSP versions, etc.). This plugin is in maintenance mode, so I recommend trying typescript.nvim, which has a much cleaner implementation of the same functionality. If you run into issues there, too, please make sure to provide version numbers as well as a minimal project that I can clone to replicate the issue on my end. |
I understand, it randomly worked this morning using my normal work flow. Opened another file and it didn't work. Thanks for responding. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
FAQ
Issues
Neovim Version
0.7.0
Steps to reproduce
Create react basic app, install a 3rd party library, go about using a component from that library, go to auto complete the missing symbol. Observe that :TsLsImportCurrent nor :TsLspImportAll import the missing symbol.
Expected behavior
A code action window appears with options
Actual behavior
'No code actions available'
Debug log
command git exited with code 0
Help
No
Implementation help
No response
The text was updated successfully, but these errors were encountered: