This problem has been plaguing me for months, and I have been apprehensive to even bring it up because it is both petty, and I suspect is a configuration error with my own setup, but I have been unable to pin down exactly where the problem is stemming from, and it is somewhat difficult and long-winded to explain via text.
The “tldr” version is that I just need to know if this occurs to anyone else so I can isolate this down to a ZLS problem, my Neovim plugins, or combination of both.
The Problem
Using Neovim on Arch Linux, when writing Zig code (both 0.13 and the master branch, though untested in previous version), typing file.close()
causes Neovim to instantly lockup. No errors are generated, and I must force-terminate the application via external commands. Consider the following:
const std = @import("std");
var file = try std.fs.openFileAbsolute("/path/to/file.ext");
defer file.close();
// ^
The instant that close
becomes the currently selected autocomplete, the application instantly freezes, never to become responsive again. This only occurs with close()
, no other function, for any other type. A close()
function on another type works perfectly fine, it only occurs with std.fs.File
.
My Neovim setup is nothing too complicated. Regarding anything LSP or auto-complete related, I don’t use anything exotic:
blink.cmp
fzf-lua
nvim-lspconfig
friendly-snippets
There are obviously some others, but nothing related to the LSP or the autocomplete, which seems to be what is triggering it.
lspconfg
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
inlay_hints = { enabled = true },
---@type lspconfig.options
servers = {
-- Zig Language Server
-- https://github.com/zigtools/zls/blob/master/schema.json
zls = {
filetypes = { "zig", "zon" },
enable_snippets = true,
enable_argument_placeholders = true,
completion_label_details = true,
semantic_tokens = "full",
inlay_hints_show_variable_type_hints = true,
inlay_hints_show_struct_literal_field_type = true,
inlay_hints_show_parameter_name = true,
inlay_hints_show_builtin = true,
inlay_hints_exclude_single_argument = false,
inlay_hints_hide_redundant_param_names = true,
inlay_hints_hide_redundant_param_names_last_token = true,
force_autofix = true,
warn_style = true,
},
},
},
},
blink.cmp
{
"saghen/blink.cmp",
opts = {
keymap = {
preset = "super-tab",
},
completion = {
keyword = { range = "full" },
ghost_text = { enabled = true },
-- Show documentation when selecting a completion item
documentation = {
auto_show = true,
auto_show_delay_ms = 500,
},
accept = { auto_brackets = { enabled = true } },
-- trigger = { show_in_snippet = false },
list = {
selection = {
preselect = function(_)
return not blink_cmp.snippet_active({ direction = 1 })
end,
-- preselect = true,
auto_insert = false,
},
},
menu = {
draw = {
gap = 1,
align_to = "label",
-- Use treesitter to highlight the label text for the given list of sources
treesitter = { "lsp" },
-- Components to render, grouped by column
columns = { { "kind_icon" }, { "label", "label_description", gap = 1 } },
},
},
-- Display a preview of the selected item on the current line
-- ghost_text = { enabled = true },
},
-- Experimental signature help support
signature = { enabled = true },
},
I apologize for the muddled verbose question, and its unimportance, but I hope someone can offer me some insights.