elixir-tools / elixir-tools.nvim

Neovim plugin for Elixir
MIT License
403 stars 30 forks source link

Error in Terminal on Exiting Vim #47

Closed bowmanmike closed 1 year ago

bowmanmike commented 1 year ago

I get the following error when exiting Vim after editing an Elixir file.

Error executing vim.schedule lua callback: ...er/start/elixir.nvim/lua/elixir/language_server/init.lua:300: Failed to insert line
stack traceback:
    [C]: in function 'nvim_buf_set_lines'
    ...er/start/elixir.nvim/lua/elixir/language_server/init.lua:300: in function 'handler'
    ...r/neovim/HEAD-050b0e3/share/nvim/runtime/lua/vim/lsp.lua:1054: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>%

Here's my elixir.nvim config:

local elixir = require("elixir")
local on_attach = require("mike.lsp_handlers").on_attach
local capabilities = require("mike.lsp_handlers").capabilities

elixir.setup({
  cmd = "/Users/mikebowman/.local/share/nvim/mason/bin/elixir-ls",

  settings = elixir.settings({
    dialyzerEnabled = true,
    fetchDeps = false,
    enableTestLenses = false,
    suggestSpecs = false
  }),

  on_attach = function(client, bufnr)
    local map_opts = { buffer = true, noremap = true }
    -- remove the pipe operator
    vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", map_opts)
    -- add the pipe operator
    vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", map_opts)
    vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", map_opts)

    on_attach(client, bufnr)
  end,
  capabilities = capabilities
})

and here's my generic LSP handlers

local M = {
  on_attach = function(client, bufnr)
    -- Mappings.
    -- See `:help vim.lsp.*` for documentation on any of the below functions
    local bufopts = { noremap = true, silent = true, buffer = bufnr }
    vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
    vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
    vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
    vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
    vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
    vim.keymap.set('n', '<leader>gwa', vim.lsp.buf.add_workspace_folder, bufopts)
    vim.keymap.set('n', '<leader>gwr', vim.lsp.buf.remove_workspace_folder, bufopts)
    vim.keymap.set('n', '<leader>gwl', function()
      print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
    end, bufopts)
    vim.keymap.set('n', '<leader>gD', vim.lsp.buf.type_definition, bufopts)
    vim.keymap.set('n', '<leader>grn', vim.lsp.buf.rename, bufopts)
    vim.keymap.set('n', '<leader>gca', vim.lsp.buf.code_action, bufopts)
    vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
    vim.keymap.set('n', '<leader>lf', function() vim.lsp.buf.format() end, bufopts)
  end,

  capabilities = require("cmp_nvim_lsp").default_capabilities()
}

return M
mhanberg commented 1 year ago

I actually was just able to unintentionally reproduce this.

I was installing a new version of the language server, but then something was wrong with the floating window so i closed it and then quit vim and then there it was.

bowmanmike commented 1 year ago

Ahh yeah I realize I forgot to add the various versions of things I'm using. ElixirLS: 0.12.0 Neovim: v0.9.0-dev-2943+g050b0e30b-dirty Elixir.nvim: 9edb86a

mhanberg commented 1 year ago

And to confirm @bowmanmike, this happens every time you exit neovim and had opened an elixir file?

do you do nvim . then open the file, or do you do nvim path/to/elixirfile.ex ?

bowmanmike commented 1 year ago

It doesn't seem to happen every time, but I haven't noticed any particular pattern. I usually open files with nvim path/to/file.

mhanberg commented 1 year ago

@bowmanmike are you using the noice.nvim plugin by any chance?

bowmanmike commented 1 year ago

Nope, not using that plugin. Here's my plugin list

LuaSnip
auto-pairs
cmp-buffer
cmp-cmdline
cmp-nvim-lsp
cmp-path
cmp_luasnip
elixir.nvim
emmet-vim
fzf
fzf.vim
git-conflict.nvim
gitsigns.nvim
hop.nvim
indent-blankline.nvim
iswap.nvim
lazygit.nvim
lspkind-nvim
lualine.nvim
mason-lspconfig.nvim
mason.nvim
null-ls.nvim
nvim-cmp
nvim-colorizer.lua
nvim-lspconfig
nvim-toggleterm.lua
nvim-tree.lua
nvim-treesitter
nvim-treesitter-textobjects
nvim-ts-autotag
nvim-ts-context-commentstring (not loaded)
nvim-ts-rainbow
nvim-web-devicons
packer.nvim
playground
plenary.nvim
popup.nvim
telescope-fzf-native.nvim
telescope.nvim
tokyonight.nvim
trouble.nvim
vim-commentary
vim-dispatch
vim-fugitive
vim-moonfly-colors
vim-projectionist
vim-repeat
vim-rhubarb
vim-surround
vim-test
ppepos commented 1 year ago

Any updates on this one? I have the exact same issue happening.

mhanberg commented 1 year ago

Hopefully fixed by https://github.com/mhanberg/elixir.nvim/commit/2d610ee2ad7e472ed3f93707b30676227324314b.

Please report back if you see it after updating