crystalline icon indicating copy to clipboard operation
crystalline copied to clipboard

No autocompletion on neovim with nvim-lspconfig

Open glyh opened this issue 1 year ago • 6 comments

I've tried to use crystalline multiple times on neovim with nvim-lspconfig, and I get no autocomplete. Is there any information on troubleshooting crystalline?

glyh avatar May 15 '24 11:05 glyh

Hello, I would like to help with this.

I'm on crystal 1.14.0, LLVM: 18.1.8 with crystalline built from 4bac6805fd80a53887bd38628c8ec9b49a9b86bc

Here's what I have with LSPInfo: image

As for LSP log it's empty.

The config is the default given by nvim-lspconfig:

https://github.com/neovim/nvim-lspconfig/blob/d141895d1d9f41048fff201d62a2d6e96d299e32/lua/lspconfig/configs/crystalline.lua#L5

Could you tell me how should I troubleshoot?

glyh avatar Oct 13 '24 16:10 glyh

Also there's even more weird behavior as this LSP delete some of my code on save when save-on-format is enabled with some other plugins on neovim.

glyh avatar Oct 13 '24 16:10 glyh

Here's a tmp fix so I can see linting, I'm still having issues with auto formatting/auto completion , though.

lspconfig.crystalline.setup {
  cmd = { "crystalline", "--stdio" },
}

glyh avatar Oct 13 '24 16:10 glyh

Hi I have the same problem with lsp based autoformat so I start using vim-crystal for auto format:

-- turn on auto format with vim-crystal:
vim.g.crystal_auto_format = 1

add vim-crystal in lazy:

{
    'vim-crystal/vim-crystal',
},

and disable lsp_fallaback for crystal files (code form modified kickstart.nvim):

  { -- Autoformat
    'stevearc/conform.nvim',
    lazy = false,
    keys = {
      {
        '<leader>f',
        function()
          require('conform').format { async = true, lsp_fallback = true }
        end,
        mode = '',
        desc = '[F]ormat buffer',
      },
    },
    opts = {
      notify_on_error = false,
      format_on_save = function(bufnr)
        -- Disable "format_on_save lsp_fallback" for languages that don't
        -- have a well standardized coding style. You can add additional
        -- languages here or re-enable it for the disabled ones.
        local disable_filetypes = { c = true, cpp = true, crystal = true }
        return {
          timeout_ms = 500,
          lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
        }
      end,
      formatters_by_ft = {
        lua = { 'stylua' },
        -- Conform can also run multiple formatters sequentially
        -- python = { "isort", "black" },
        --
        -- You can use a sub-list to tell conform to run *until* a formatter
        -- is found.
        -- javascript = { { "prettierd", "prettier" } },
      },
    },
  },

and3md avatar Oct 13 '24 18:10 and3md

Hello, thanks, that works now. Only thing that is broken is autocompletion now.

EDIT: it looks like we actually do have auto completion. It's just the quality of autocompletion is pretty bad.

glyh avatar Oct 14 '24 05:10 glyh

Hello, thanks, that works now. Only thing that is broken is autocompletion now.

EDIT: it looks like we actually do have auto completion. It's just the quality of autocompletion is pretty bad.

It seems to work in the main source file but in others it works quite randomly

and3md avatar Oct 14 '24 09:10 and3md