jose-elias-alvarez / nvim-lsp-ts-utils

Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
The Unlicense
438 stars 18 forks source link

[BUG] `:TSLspImportAll` doesn't work on Neovim nightly 0.7 #107

Closed mawkler closed 2 years ago

mawkler commented 2 years ago

FAQ

Issues

Neovim Version

NVIM v0.7.0-dev+1027-gf02a5a7bd

Steps to reproduce

  1. Use the following init.vim:

    call plug#begin('~/.config/nvim/packages/')
    Plug 'neovim/nvim-lspconfig'
    Plug 'nvim-lua/plenary.nvim'
    Plug 'williamboman/nvim-lsp-installer'
    Plug 'jose-elias-alvarez/nvim-lsp-ts-utils'
    call plug#end()
    
    lua << EOF
    local typescript_settings = {
     init_options = require('nvim-lsp-ts-utils').init_options,
     on_attach = function(client)
       local ts_utils = require('nvim-lsp-ts-utils')
       ts_utils.setup({
         update_imports_on_move = true,
         inlay_hints_highlight = 'NvimLspTSUtilsInlineHint',
         degbug = true
       })
       ts_utils.setup_client(client)
     end
    }
    
    require('nvim-lsp-installer').on_server_ready(function(server)
     server:setup(typescript_settings)
     vim.cmd 'do User LspAttachBuffers'
    end)
    EOF
  2. Open a TypeScript file

  3. Delete some file imports at the top so that there are code actions available for importing them again

  4. Do :TSLspImportAll

  5. Error should appear

Expected behavior

nvim-lsp-ts-utils would add the missing import statements

Actual behavior

Neovim prints the following error:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:366: offset_encoding: expected string, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:366: in function 'apply_text_edits'
        ...s/nvim-lsp-ts-utils/lua/nvim-lsp-ts-utils/import-all.lua:206: in function 'apply_edits'
        ...s/nvim-lsp-ts-utils/lua/nvim-lsp-ts-utils/import-all.lua:279: in function <...s/nvim-lsp-ts-utils/lua/nvim-lsp-ts-utils/import-all.lua:278>

Debug log

git root found at *path/to/project/*; scanning
watching dir *path/to/project/file*
command git exited with code 0
assigning priority 0 to action Import 'Logger' from module "@azure/functions"
Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:366: offset_encoding: expected string, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:366: in function 'apply_text_edits'
        ...s/nvim-lsp-ts-utils/lua/nvim-lsp-ts-utils/import-all.lua:206: in function 'apply_edits'
        ...s/nvim-lsp-ts-utils/lua/nvim-lsp-ts-utils/import-all.lua:279: in function <...s/nvim-lsp-ts-utils/lua/nvim-lsp-ts-utils/import-all.lua:278>

Help

No

Implementation help

No response

jose-elias-alvarez commented 2 years ago

Should be fixed by 337e4fa31d88e5553edeb05ac572bacd4a24d867.

mawkler commented 2 years ago

Yes it's fixed, thank you!