Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nightly release tsserver omnifunc doesn't complete partial identifier #29284

Open
paskozdilar opened this issue Jun 11, 2024 · 0 comments
Open
Labels
bug issues reporting wrong behavior lsp

Comments

@paskozdilar
Copy link

Problem

Nightly release of Neovim has issues with tsserver omnifunc.

Example files:

// mymodule.ts
export function foo() {}
export function bar() {}

// index.ts
import { } from './mymodule';

Opening index.ts, typing f between the brackets, then pressing <C-x><C-o> autocompletes to bar - lexicographically first identifier, instead of foo, which would complete the f input.


I've written a Dockerfile that reproduces this issue with minimum configuration:

FROM node:18

WORKDIR /root/app

# install nightly nvim
RUN wget https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
RUN tar -xzvf nvim-linux64.tar.gz

# install lspconfig
RUN git clone -b v0.1.8 https://github.com/neovim/nvim-lspconfig ~/.config/nvim/pack/nvim/start/nvim-lspconfig

# install typescript and tsserver
RUN npm install -g typescript typescript-language-server

# create tsserver configuration
RUN mkdir -p ~/.config/nvim/
RUN echo "luafile $HOME/.config/nvim/lspconfig.lua" >> ~/.config/nvim/init.vim
RUN echo "local lspconfig = require('lspconfig')" >> ~/.config/nvim/lspconfig.lua
RUN echo "lspconfig.tsserver.setup{}" >> ~/.config/nvim/lspconfig.lua
RUN echo "vim.api.nvim_create_autocmd('LspAttach', {" >> ~/.config/nvim/lspconfig.lua
RUN echo "    group = vim.api.nvim_create_augroup('UserLspConfig', {})," >> ~/.config/nvim/lspconfig.lua
RUN echo "    callback = function(ev)" >> ~/.config/nvim/lspconfig.lua
RUN echo "        -- Enable completion triggered by <c-x><c-o>" >> ~/.config/nvim/lspconfig.lua
RUN echo "        vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'" >> ~/.config/nvim/lspconfig.lua
RUN echo "    end," >> ~/.config/nvim/lspconfig.lua
RUN echo "})" >> ~/.config/nvim/lspconfig.lua

# create example project
RUN npm init --force
RUN tsc --init
RUN echo "export function foo() {}" >> mymodule.ts
RUN echo "export function bar() {}" >> mymodule.ts
RUN echo "import { } from './mymodule';" >> index.ts

ENTRYPOINT "/root/app/nvim-linux64/bin/nvim"

Build the image, run it, and type :e index.ts<Return>wwif<C-x><C-o> - omnifunc will complete bar instead of foo.


By contrast, here is a Dockerfile in which the omnifunc correctly completes foo:

FROM node:18

WORKDIR /root/app

# install release nvim
RUN wget https://github.com/neovim/neovim/releases/download/v0.10.0/nvim-linux64.tar.gz
RUN tar -xzvf nvim-linux64.tar.gz

# install lspconfig
RUN git clone -b v0.1.8 https://github.com/neovim/nvim-lspconfig ~/.config/nvim/pack/nvim/start/nvim-lspconfig

# install typescript and tsserver
RUN npm install -g typescript typescript-language-server

# create tsserver configuration
RUN mkdir -p ~/.config/nvim/
RUN echo "luafile $HOME/.config/nvim/lspconfig.lua" >> ~/.config/nvim/init.vim
RUN echo "local lspconfig = require('lspconfig')" >> ~/.config/nvim/lspconfig.lua
RUN echo "lspconfig.tsserver.setup{}" >> ~/.config/nvim/lspconfig.lua
RUN echo "vim.api.nvim_create_autocmd('LspAttach', {" >> ~/.config/nvim/lspconfig.lua
RUN echo "    group = vim.api.nvim_create_augroup('UserLspConfig', {})," >> ~/.config/nvim/lspconfig.lua
RUN echo "    callback = function(ev)" >> ~/.config/nvim/lspconfig.lua
RUN echo "        -- Enable completion triggered by <c-x><c-o>" >> ~/.config/nvim/lspconfig.lua
RUN echo "        vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'" >> ~/.config/nvim/lspconfig.lua
RUN echo "    end," >> ~/.config/nvim/lspconfig.lua
RUN echo "})" >> ~/.config/nvim/lspconfig.lua

# create example project
RUN npm init --force
RUN tsc --init
RUN echo "export function foo() {}" >> mymodule.ts
RUN echo "export function bar() {}" >> mymodule.ts
RUN echo "import { } from './mymodule';" >> index.ts

ENTRYPOINT "/root/app/nvim-linux64/bin/nvim"

Steps to reproduce using "nvim -u minimal_init.lua"

local lspconfig = require('lspconfig')
lspconfig.tsserver.setup{}
vim.api.nvim_create_autocmd('LspAttach', {
    group = vim.api.nvim_create_augroup('UserLspConfig', {}),
    callback = function(ev)
        -- Enable completion triggered by <c-x><c-o>
        vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
    end,
})

Expected behavior

Expected behavior:

2024-06-11_14-09-36.mp4

Actual behavior:

2024-06-11_14-12-12.mp4

Neovim version (nvim -v)

NVIM v0.11.0-dev-211+g37bf4c572

Language server name/version

[email protected]

Operating system/version

Ubuntu 22.04

Log file

https://gist.github.com/paskozdilar/a3c8391ff427e432449ef6e8dd70cd52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior lsp
Projects
None yet
Development

No branches or pull requests

1 participant