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

nerdfonts break lsp semantic tokens #605

Closed
DockterTeagle opened this issue Oct 8, 2024 · 1 comment
Closed

nerdfonts break lsp semantic tokens #605

DockterTeagle opened this issue Oct 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@DockterTeagle
Copy link

DockterTeagle commented Oct 8, 2024

Describe the bug
A clear and concise description of what the bug is.
when using a nerdfont(as I cant get the Unicode characters to work with home-manager writing oh-my-posh) I get an error related to lsp semantic tokens which is this:

Error executing vim.schedule lua callback: ....10.2/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:304: ....10.2/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:149: index out of range
stack traceback:
	[builtin#36]: at 0x7f4f65b8de00
	....10.2/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:304: in function 'handler'
	...wrapped-0.10.2/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>
	

Logs (Required)

[DEBUG][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 14,            line = 63          },          start = {            character = 12,            line = 63          }        },        rangeLength = 2,        text = ""      } },    textDocument = {      uri = "file:///home/cdockter/MyNixOS/users/cdockter/configs/terminal/zsh.nix",      version = 3    }  }}
[DEBUG][2024-10-08 12:00:09] ...m/lsp/client.lua:678	"LSP[nixd]"	"client.request"	1	"textDocument/inlayHint"	{  range = {    ["end"] = {      character = 0,      line = 326    },    start = {      character = 0,      line = 0    }  },  textDocument = {    uri = "file:///home/cdockter/MyNixOS/users/cdockter/configs/terminal/zsh.nix"  }}	<function 1>	9
[DEBUG][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 5,  jsonrpc = "2.0",  method = "textDocument/inlayHint",  params = {    range = {      ["end"] = {        character = 0,        line = 326      },      start = {        character = 0,        line = 0      }    },    textDocument = {      uri = "file:///home/cdockter/MyNixOS/users/cdockter/configs/terminal/zsh.nix"    }  }}
[ERROR][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:770	"rpc"	"/run/current-system/sw/bin/nixd"	"stderr"	"I[12:00:09.895] 1262035: <-- textDocument/didChange\n"
[ERROR][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:770	"rpc"	"/run/current-system/sw/bin/nixd"	"stderr"	"I[12:00:09.896] 1262035: --> notify textDocument/publishDiagnostics\n"
[DEBUG][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = { {        code = "sema-unused-def-let",        message = "definition `ohMyPoshConfig` in let-expression is not used",        range = {          ["end"] = {            character = 16,            line = 49          },          start = {            character = 2,            line = 49          }        },        relatedInformation = {},        severity = 2,        source = "nixf",        tags = { 1 }      } },    uri = "file:///home/cdockter/MyNixOS/users/cdockter/configs/terminal/zsh.nix",    version = 3  }}
[DEBUG][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 5,  jsonrpc = "2.0",  result = {}}
[ERROR][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:770	"rpc"	"/run/current-system/sw/bin/nixd"	"stderr"	"I[12:00:09.896] 1262035: <-- textDocument/inlayHint(5)\nI[12:00:09.896] 1262035: --> reply:textDocument/inlayHint(5)\n"
[DEBUG][2024-10-08 12:00:09] ...m/lsp/client.lua:678	"LSP[nixd]"	"client.request"	1	"textDocument/semanticTokens/full"	{  textDocument = {    uri = "file:///home/cdockter/MyNixOS/users/cdockter/configs/terminal/zsh.nix"  }}	<function 1>	9
[DEBUG][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 6,  jsonrpc = "2.0",  method = "textDocument/semanticTokens/full",  params = {    textDocument = {      uri = "file:///home/cdockter/MyNixOS/users/cdockter/configs/terminal/zsh.nix"    }  }}
[ERROR][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:770	"rpc"	"/run/current-system/sw/bin/nixd"	"stderr"	"I[12:00:09.945] 1262035: <-- textDocument/semanticTokens/full(6)\n"
[ERROR][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:770	"rpc"	"/run/current-system/sw/bin/nixd"	"stderr"	"I[12:00:09.946] 1262035: --> reply:textDocument/semanticTokens/full(6)\n"
[DEBUG][2024-10-08 12:00:09] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 6,  jsonrpc = "2.0",  result = {    data = { 49, 2, 14, 10, 0, 2, 4, 9, 10, 0, 0, 12, 85, 1, 0, 1, 4, 6, 10, 0, 2, 8, 4, 10, 0, 0, 7, 8, 1, 0, 1, 8, 9, 10, 0, 0, 12, 6, 1, 0, 1, 8, 8, 10, 0, 2, 12, 4, 10, 0, 0, 7, 7, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 2, 12, 8, 10, 0, 0, 11, 16, 1, 0, 3, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 35, 1, 0, 3, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 11, 1, 0, 1, 12, 16, 10, 0, 0, 19, 8, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 28, 1, 0, 1, 12, 10, 10, 0, 1, 14, 11, 10, 0, 0, 14, 10, 1, 0, 1, 14, 9, 10, 0, 0, 12, 8, 1, 0, 1, 14, 5, 10, 0, 0, 8, 8, 1, 0, 4, 12, 4, 10, 0, 0, 7, 5, 1, 0, 1, 12, 5, 10, 0, 0, 8, 11, 1, 0, 1, 12, 16, 10, 0, 0, 19, 8, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 20, 10, 0, 1, 14, 67, 1, 0, 1, 14, 59, 1, 0, 1, 14, 38, 1, 0, 1, 14, 39, 1, 0, 2, 12, 8, 10, 0, 0, 11, 283, 1, 0, 1, 12, 10, 10, 0, 1, 14, 11, 10, 0, 0, 14, 8, 1, 0, 1, 14, 12, 10, 0, 0, 15, 4, 9, 1, 1, 14, 19, 10, 0, 0, 22, 4, 9, 1, 4, 12, 4, 10, 0, 0, 7, 15, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 16, 10, 0, 0, 19, 8, 1, 0, 1, 12, 8, 10, 0, 0, 11, 34, 1, 0, 1, 12, 10, 10, 0, 1, 14, 5, 10, 0, 0, 8, 11, 1, 0, 1, 14, 9, 10, 0, 6, 8, 4, 10, 0, 0, 7, 8, 1, 0, 1, 8, 9, 10, 0, 0, 12, 7, 1, 0, 1, 8, 8, 10, 0, 2, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 83, 1, 0, 1, 12, 10, 10, 0, 1, 14, 21, 10, 0, 0, 24, 4, 9, 1, 1, 14, 8, 10, 0, 0, 11, 22, 1, 0, 1, 14, 9, 10, 0, 0, 12, 21, 1, 0, 4, 12, 4, 10, 0, 0, 7, 8, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 101, 1, 0, 3, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 66, 1, 0, 3, 12, 4, 10, 0, 0, 7, 8, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 66, 1, 0, 3, 12, 4, 10, 0, 0, 7, 4, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 66, 1, 0, 3, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 3, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 9, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 66, 1, 0, 3, 12, 4, 10, 0, 0, 7, 9, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 9, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 66, 1, 0, 3, 12, 4, 10, 0, 0, 7, 4, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 9, 1, 0, 1, 12, 16, 10, 0, 0, 19, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 62, 1, 0, 3, 12, 4, 10, 0, 0, 7, 4, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 35, 1, 0, 1, 12, 8, 10, 0, 0, 11, 42, 1, 0, 1, 12, 10, 10, 0, 1, 14, 5, 10, 0, 0, 8, 8, 1, 0, 1, 14, 5, 10, 0, 0, 8, 8, 1, 0, 1, 14, 7, 10, 0, 0, 10, 8, 1, 0, 4, 12, 4, 10, 0, 0, 7, 9, 1, 0, 1, 12, 5, 10, 0, 0, 8, 11, 1, 0, 1, 12, 16, 10, 0, 0, 19, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 4, 9, 1, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 20, 10, 0, 1, 14, 52, 1, 0, 1, 14, 55, 1, 0, 1, 14, 48, 1, 0, 2, 12, 8, 10, 0, 0, 11, 78, 1, 0, 1, 12, 10, 10, 0, 1, 14, 12, 10, 0, 0, 15, 9, 1, 0, 1, 14, 13, 10, 0, 0, 16, 9, 1, 0, 1, 14, 16, 10, 0, 0, 19, 9, 1, 0, 4, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 9, 1, 0, 1, 12, 16, 10, 0, 0, 19, 4, 9, 1, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 15, 10, 0, 0, 18, 8, 1, 0, 1, 12, 16, 10, 0, 0, 19, 8, 1, 0, 1, 12, 8, 10, 0, 0, 11, 44, 1, 0, 1, 12, 10, 10, 0, 1, 14, 11, 10, 0, 0, 14, 10, 1, 0, 6, 8, 4, 10, 0, 0, 7, 8, 1, 0, 1, 8, 9, 10, 0, 0, 12, 6, 1, 0, 1, 8, 8, 10, 0, 2, 12, 4, 10, 0, 0, 7, 6, 1, 0, 1, 12, 5, 10, 0, 0, 8, 7, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 8, 10, 0, 0, 11, 14, 1, 0, 3, 12, 4, 10, 0, 0, 7, 8, 1, 0, 1, 12, 5, 10, 0, 0, 8, 7, 1, 0, 1, 12, 10, 10, 0, 0, 13, 9, 1, 0, 1, 12, 20, 10, 0, 1, 14, 37, 1, 0, 2, 12, 8, 10, 0, 0, 11, 15, 1, 0, 1, 12, 10, 10, 0, 1, 14, 14, 10, 0, 0, 17, 4, 9, 1, 4, 8, 7, 10, 0, 0, 10, 4, 9, 1, 3, 4, 7, 10, 0, 4, 2, 4, 10, 0, 1, 4, 12, 10, 0, 1, 6, 15, 10, 0, 0, 18, 33, 1, 0, 1, 6, 13, 10, 0, 0, 16, 165, 1, 0, 1, 6, 2, 10, 0, 0, 5, 3, 1, 0, 3, 2, 8, 10, 0, 1, 4, 6, 10, 0, 1, 6, 6, 10, 0, 0, 9, 4, 9, 1, 1, 6, 20, 10, 0, 0, 23, 4, 9, 1, 1, 6, 21, 10, 0, 0, 24, 4, 9, 1, 2, 4, 3, 10, 0, 1, 6, 6, 10, 0, 0, 9, 4, 9, 1, 1, 6, 14, 10, 0, 0, 15, 6, 10, 0, 0, 9, 4, 9, 1, 1, 6, 6, 10, 0, 0, 9, 13, 1, 0, 1, 6, 18, 10, 0, 0, 19, 6, 10, 0, 0, 9, 4, 9, 1, 1, 6, 9, 10, 0, 7, 6, 9, 10, 0, 1, 8, 6, 10, 0, 0, 9, 4, 9, 1, 1, 8, 7, 10, 0, 0, 12, 5, 1, 0, 0, 6, 9, 1, 0, 0, 10, 19, 1, 0, 0, 20, 4, 1, 0, 0, 5, 8, 1, 0, 0, 9, 6, 1, 0, 0, 7, 14, 1, 0, 3, 4, 10, 10, 0, 1, 6, 6, 10, 0, 0, 9, 4, 9, 1, 1, 6, 21, 10, 0, 0, 24, 4, 9, 1, 1, 6, 20, 10, 0, 0, 23, 4, 9, 1, 2, 6, 8, 10, 0, 0, 11, 8, 1, 0 },    resultId = ""  }}

Configuration

If you have some custom configuration, please paste it here.

M.on_attach = function(client, bufnr)
	local function opts(desc)
		return { buffer = bufnr, desc = "LSP " .. desc }
	end
	if client.server_capabilities.inlayHintProvider then
		vim.lsp.inlay_hint.enable(true)
	end
	vim.lsp.set_log_level("debug")
	map("n", "gD", vim.lsp.buf.declaration, opts("Go to declaration"))
	map("n", "gd", vim.lsp.buf.definition, opts("Go to definition"))
	map("n", "gi", vim.lsp.buf.implementation, opts("Go to implementation"))
	map("n", "<leader>sh", vim.lsp.buf.signature_help, opts("Show signature help"))
	map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts("Add workspace folder"))
	map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts("Remove workspace folder"))

	map("n", "<leader>wl", function()
		print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
	end, opts("List workspace folders"))

	map("n", "<leader>D", vim.lsp.buf.type_definition, opts("Go to type definition"))

	map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts("Code action"))
	map("n", "gr", vim.lsp.buf.references, opts("Show references"))
end
...
M.capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())

M.capabilities.textDocument.completion.completionItem = {
	documentationFormat = { "markdown", "plaintext" },
	snippetSupport = true,
	preselectSupport = true,
	insertReplaceSupport = true,
	labelDetailsSupport = true,
	deprecatedSupport = true,
	commitCharactersSupport = true,
	tagSupport = { valueSet = { 1 } },
	resolveSupport = {
		properties = {
			"documentation",
			"detail",
			"additionalTextEdits",
		},
	},
}
...

this file is then imported to lspconfg

lspconfig.nixd.setup({
	on_attach = on_attach,
	capabilities = capabilities,
	cmd = { "nixd" },
	-- settings = {
	-- 	nixd = {
	-- 		autowatch = true,
	-- 		nixpkgs = {
	-- 			expr = 'import (builtins.getFlake "/home/cdockter/MyNixOS/").inputs.nixpkgs { }',
	-- 		},
	-- 		formatting = {
	-- 			command = { "nixpkgs-fmt" },
	-- 		},
	-- 		options = {
	-- 			nixos = {
	-- 				expr = '(builtins.getFlake "/home/cdockter/MyNixOS/").nixosConfigurations.nixos.options',
	-- 			},
	-- 			home_manager = {
	-- 				expr = '(builtins.getFlake "/home/cdockter/MyNixOS").homeConfigurations."cdockter".options',
	-- 			},
	-- 			flake_parts = {
	-- 				expr = '(builtins.getFlake "/home/cdockter/MyNixOS").debug.options',
	-- 			},
	-- 		},
	-- 	},
	-- },
})

To Reproduce

  1. add a nerdfont character to any nix file(in an attribute set)
  2. write file
  3. bug appears

Expected behavior
this error to not appear. I dont know if semantic tokens are enabled or planned at all.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@DockterTeagle DockterTeagle added the bug Something isn't working label Oct 8, 2024
@inclyc
Copy link
Member

inclyc commented Oct 9, 2024

Duplicate of #604

@inclyc inclyc marked this as a duplicate of #604 Oct 9, 2024
@inclyc inclyc closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants