nvim-lspconfig icon indicating copy to clipboard operation
nvim-lspconfig copied to clipboard

Unable to use emojis as diagnostic signs

Open leap0x7b opened this issue 3 years ago β€’ 1 comments

Description

Error detected while processing /data/data/com.termux/files/home/.config/nvim/init.lua:
E5113: Error while calling lua chunk: Vim:E239: Invalid sign text: πŸ’‘
stack traceback:
        [C]: in function 'sign_define'
        /data/data/com.termux/files/home/.config/nvim/init.lua:35: in main chunk
Press ENTER or type command to continue

Neovim version

NVIM v0.8.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang -fstack-protector-strong -Oz --target=aarch64-linux-android24 -I/data/data/com.termux/files/usr/include -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/builder/.termux-build/neovim-nightly/build/cmake.config -I/home/builder/.termux-build/neovim-nightly/src/src -I/data/data/com.termux/files/usr/include -I/home/builder/.termux-build/neovim-nightly/build/src/nvim/auto -I/home/builder/.termux-build/neovim-nightly/build/include Compiled by builder@7bab2cdea466

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/data/data/com.termux/files/usr/share/nvim"

Run :checkhealth for more info

Nvim-lspconfig version

No response

Operating system and version

Termux (Android 10)

Affected language servers

all

Steps to reproduce

Add these line of code

local signs = { Error = "Γ— ", Warn = "ο”© ", Hint = "πŸ’‘ ", Info = "Β‘ " }
for type, icon in pairs(signs) do
  local hl = "DiagnosticSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end

Actual behavior

It errors out with the error I included in the description above

Expected behavior

πŸ’‘ should be set as the hint sign

Minimal config

local on_windows = vim.loop.os_uname().version:match 'Windows'

local function join_paths(...)
  local path_sep = on_windows and '\\' or '/'
  local result = table.concat({ ... }, path_sep)
  return result
end

vim.cmd [[set runtimepath=$VIMRUNTIME]]

local temp_dir = vim.loop.os_getenv 'TEMP' or '/tmp'

vim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))

local package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')
local install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')
local compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')

local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      'neovim/nvim-lspconfig',
    },
    config = {
      package_root = package_root,
      compile_path = compile_path,
    },
  }
end

_G.load_config = function()
  vim.lsp.set_log_level 'trace'
  if vim.fn.has 'nvim-0.5.1' == 1 then
    require('vim.lsp.log').set_format_func(vim.inspect)
  end
  local nvim_lsp = require 'lspconfig'
  local on_attach = function(_, bufnr)
    local function buf_set_option(...)
      vim.api.nvim_buf_set_option(bufnr, ...)
    end

    buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

    -- Mappings.
    local opts = { buffer = bufnr, noremap = true, silent = true }
    vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
    vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
    vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
    vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
    vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
    vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
    vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
    vim.keymap.set('n', '<space>wl', function()
      print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
    end, opts)
    vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
    vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
    vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
    vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
    vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
    vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
    vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
  end

  local signs = { Error = "Γ— ", Warn = "ο”© ", Hint = "πŸ’‘ ", Info = "Β‘ " }
  for type, icon in pairs(signs) do
    local hl = "DiagnosticSign" .. type
    vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
  end

  -- Add the server that troubles you here
  local name = 'pyright'
  local cmd = { 'pyright-langserver', '--stdio' } -- needed for elixirls, omnisharp, sumneko_lua
  if not name then
    print 'You have not defined a server name, please edit minimal_init.lua'
  end
  if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
    print [[You have not defined a server default cmd for a server
      that requires it please edit minimal_init.lua]]
  end

  nvim_lsp[name].setup {
    cmd = cmd,
    on_attach = on_attach,
  }

  print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
  load_plugins()
  require('packer').sync()
  vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
else
  load_plugins()
  require('packer').sync()
  _G.load_config()
end

LSP log

I used nvim-cmp, nvim-lspconfig for some reason doesn't generate the $HOME/.cache/nvim/lsp.log file so I can't include it here

leap0x7b avatar Jul 30 '22 06:07 leap0x7b

Your sign should only take up to 2 characters at most, and πŸ’‘is counted as two characters already. Remove the whitespace and it should work. or use a single character Unicode glyph.

like this: Hint = "πŸ’‘ " to this: Hint = "πŸ’‘"

cevhyruz avatar Jul 30 '22 08:07 cevhyruz