0

I am configuring native lsp of neovim. I have installed neovim-lsp and neovim-lspconfig plugins using vimplug. I have also installed hrsh7th/nvim-compe for auto completion suggestions.

Functionally these tthings work, but I don't get to see the colors for the error, warning icons. They just come with a white outline as shown in the attachement.

Secondly, since I also installed gitgutter, there seems to be conflict between showing gitgutter signs suchas (addition, deletion, modification) changes, Vs the error code on a newly added line. That is, if a code line is newly added, but it contains an error, then the gitgutter is taking priority to show the + symbol, rather than the error.

How do I make these two things work correct. enter image description here

Here is my lsp-config.lua: The file has lot of content (copy pasted from examples, so I don't understand much of lua scripting or vim commands mapping)

╰─ cat ~/.config/nvim/lua/lsp-config.lua
local nvim_lsp = require("lspconfig")
local format_async = function(err, _, result, _, bufnr)
if err ~= nil or result == nil then return end
if not vim.api.nvim_buf_get_option(bufnr, "modified") then
local view = vim.fn.winsaveview()
vim.lsp.util.apply_text_edits(result, bufnr)
vim.fn.winrestview(view)
if bufnr == vim.api.nvim_get_current_buf() then
vim.api.nvim_command("noautocmd :update")
end
end
end
vim.lsp.handlers["textDocument/formatting"] = format_async
_G.lsp_organize_imports = function()
local params = {
command = "_typescript.organizeImports",
arguments = {vim.api.nvim_buf_get_name(0)},
title = ""
}
vim.lsp.buf.execute_command(params)
end
local on_attach = function(client, bufnr)
local buf_map = vim.api.nvim_buf_set_keymap
vim.cmd("command! LspDef lua vim.lsp.buf.definition()")
vim.cmd("command! LspFormatting lua vim.lsp.buf.formatting()")
vim.cmd("command! LspCodeAction lua vim.lsp.buf.code_action()")
vim.cmd("command! LspHover lua vim.lsp.buf.hover()")
vim.cmd("command! LspRename lua vim.lsp.buf.rename()")
vim.cmd("command! LspOrganize lua lsp_organize_imports()")
vim.cmd("command! LspRefs lua vim.lsp.buf.references()")
vim.cmd("command! LspTypeDef lua vim.lsp.buf.type_definition()")
vim.cmd("command! LspImplementation lua vim.lsp.buf.implementation()")
vim.cmd("command! LspDiagPrev lua vim.lsp.diagnostic.goto_prev()")
vim.cmd("command! LspDiagNext lua vim.lsp.diagnostic.goto_next()")
vim.cmd(
"command! LspDiagLine lua vim.lsp.diagnostic.show_line_diagnostics()")
vim.cmd("command! LspSignatureHelp lua vim.lsp.buf.signature_help()")
buf_map(bufnr, "n", "gd", ":LspDef<CR>", {silent = true})
buf_map(bufnr, "n", "gr", ":LspRename<CR>", {silent = true})
buf_map(bufnr, "n", "gR", ":LspRefs<CR>", {silent = true})
buf_map(bufnr, "n", "gy", ":LspTypeDef<CR>", {silent = true})
buf_map(bufnr, "n", "K", ":LspHover<CR>", {silent = true})
buf_map(bufnr, "n", "gs", ":LspOrganize<CR>", {silent = true})
buf_map(bufnr, "n", "[a", ":LspDiagPrev<CR>", {silent = true})
buf_map(bufnr, "n", "]a", ":LspDiagNext<CR>", {silent = true})
buf_map(bufnr, "n", "ga", ":LspCodeAction<CR>", {silent = true})
buf_map(bufnr, "n", "<Leader>a", ":LspDiagLine<CR>", {silent = true})
buf_map(bufnr, "i", "<C-x><C-x>", "<cmd> LspSignatureHelp<CR>",
{silent = true})
if client.resolved_capabilities.document_formatting then
vim.api.nvim_exec([[
augroup LspAutocommands
autocmd! * <buffer>
autocmd BufWritePost <buffer> LspFormatting
augroup END
]], true)
end
end
nvim_lsp.tsserver.setup {
on_attach = function(client)
client.resolved_capabilities.document_formatting = false
on_attach(client)
end
}
local filetypes = {
typescript = "eslint",
typescriptreact = "eslint",
}
local linters = {
eslint = {
sourceName = "eslint",
command = "eslint_d",
rootPatterns = {".eslintrc.js", "package.json"},
debounce = 100,
args = {"--stdin", "--stdin-filename", "%filepath", "--format", "json"},
parseJson = {
errorsRoot = "[0].messages",
line = "line",
column = "column",
endLine = "endLine",
endColumn = "endColumn",
message = "${message} [${ruleId}]",
security = "severity"
},
securities = {[2] = "error", [1] = "warning"}
}
}
local formatters = {
prettier = {command = "prettier", args = {"--stdin-filepath", "%filepath"}}
}
local formatFiletypes = {
typescript = "prettier",
typescriptreact = "prettier"
}
nvim_lsp.diagnosticls.setup {
on_attach = on_attach,
filetypes = vim.tbl_keys(filetypes),
init_options = {
filetypes = filetypes,
linters = linters,
formatters = formatters,
formatFiletypes = formatFiletypes
}
}


-- use .ts snippets in .tsx files
vim.g.vsnip_filetypes = {
typescriptreact = {"typescript"}
}
require"compe".setup {
preselect = "always",
source = {
path = true,
buffer = true,
vsnip = true,
nvim_lsp = true,
nvim_lua = true
}
}

Thanks to anyone helping me to get this working properly.

2
  • Please edit after following some steps in How to debug my vimrc so that we have a minimal example. You might have to check your font (icons are tricky) and encoding (multi-byte characters?). As for sign priority, see :help sign-priority—probably the two plugins just aren't co-operating for the signs.
    – D. Ben Knoble
    Aug 12, 2021 at 14:05
  • Can you try a different colorscheme?
    – PyGamer0
    Aug 14, 2021 at 14:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.