ionide / Ionide-vim

F# Vim plugin based on FsAutoComplete and LSP protocol
MIT License
174 stars 21 forks source link

Autocompletion not working if not on the start of the line #53

Closed quantum-booty closed 2 years ago

quantum-booty commented 2 years ago

[Edit]: looks like this is a problem of FSAutoComplete instead of Ionide, because I still don't get autocompletion even if I use FsAutoComplete directly using the built-in lsp: nvim_lsp.fsautocomplete.setup{ capabilities = capabilities, on_attach = on_attach }

Completion works if I type from the beginning of the line. image

But if there is anything before my cursor, autocompletion does not work. image

I also see error when starting a new line in a function block: image

** Environmen: OS: Archlinux Vim / Neovim version: NVIM v0.7.0-dev+1241-g08d9d74fd dotnet SDK version: 6.0.102 mono / .Net Framework version: 6.0.102

Here is my Neovim configuration to setup the lsp:

local map = require('utils').map
local opts = { noremap=true, silent=true }

vim.opt.updatetime = 250
vim.opt.completeopt:append({'menuone','noselect','noinsert'})
vim.opt.completeopt:remove('preview')
vim.opt.shortmess:append('c')

local nvim_lsp = require('lspconfig')
local on_attach = function(client, bufnr)
    local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
    local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
    buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

    buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
    buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
    buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
    buf_set_keymap('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)

    buf_set_keymap('n', 'gn', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
    buf_set_keymap('n', 'gp', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)

    buf_set_keymap('n', '<tab>', '<cmd>lua vim.lsp.buf.hover({border = "single"})<CR>', opts)
    buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    buf_set_keymap('n', '<leader>rr', '<cmd>LspRestart<CR>', opts)
    buf_set_keymap('n', '<leader>=', '<cmd>set ff=unix<cr><cmd>lua vim.lsp.buf.formatting_sync()<CR>', opts)

    buf_set_keymap('n', '<LeftMouse>', '<LeftMouse><cmd>lua vim.lsp.buf.hover({border = "single"})<CR>', opts)
    buf_set_keymap('n', '<RightMouse>', '<LeftMouse><cmd>lua vim.lsp.buf.definition()<CR>', opts)

end

capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())

vim.cmd([[
let g:fsharp#lsp_auto_setup = 0
let g:fsharp#exclude_project_directories = ['paket-files']
]])
require'ionide'.setup{ capabilities = capabilities, on_attach = on_attach}
baronfel commented 2 years ago

Brief note - this is an upstream bug in FSAC, working on a fix.

baronfel commented 2 years ago

This should be fixed in 0.50.1, fresh off the presses. @quantum-booty can you verify and close if appropriate?

cannorin commented 2 years ago

I can't reproduce this, so the issue seems to be solved.