Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Suppress lang servers error messages (#69)
Browse files Browse the repository at this point in the history
Particularly useful when using problematic language servers like `diagnosticls` and `efm`
  • Loading branch information
pocco81 authored Jul 25, 2021
1 parent 4dea8d3 commit 4f39029
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 62 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@
"contributions": [
"bug"
]
},
{
"login": "AceMouty",
"name": "Kyle Guerrero",
"avatar_url": "https://avatars.githubusercontent.com/u/45374681?v=4",
"profile": "https://github.com/AceMouty",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
![Neovim version](https://img.shields.io/badge/Neovim-0.5-57A143?style=for-the-badge&logo=neovim)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[Features](#features)[Install](#install)[Documentation][Contribute](#contribute)
Expand Down Expand Up @@ -177,6 +177,7 @@ Special thanks to these amazing people for helping improve doom (see [emoji key]
<td align="center"><a href="https://github.com/notusknot"><img src="https://avatars.githubusercontent.com/u/69602000?v=4?s=100" width="100px;" alt=""/><br /><sub><b>notusknot</b></sub></a><br /><a href="https://github.com/NTBBloodbath/doom-nvim/commits?author=notusknot" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/bdillahu"><img src="https://avatars.githubusercontent.com/u/2058566?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bruce Dillahunty</b></sub></a><br /><a href="https://github.com/NTBBloodbath/doom-nvim/commits?author=bdillahu" title="Documentation">📖</a> <a href="https://github.com/NTBBloodbath/doom-nvim/issues?q=author%3Abdillahu" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/amxj9"><img src="https://avatars.githubusercontent.com/u/2029709?v=4?s=100" width="100px;" alt=""/><br /><sub><b>amxj9</b></sub></a><br /><a href="https://github.com/NTBBloodbath/doom-nvim/issues?q=author%3Aamxj9" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/AceMouty"><img src="https://avatars.githubusercontent.com/u/45374681?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kyle Guerrero</b></sub></a><br /><a href="https://github.com/NTBBloodbath/doom-nvim/commits?author=AceMouty" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
150 changes: 89 additions & 61 deletions lua/doom/modules/config/doom-lspconfig.lua
Original file line number Diff line number Diff line change
@@ -1,66 +1,94 @@
local fn = vim.fn
local lsp = vim.lsp

return function()
local config = require('doom.core.config').load_config()
local config = require("doom.core.config").load_config()

-- Snippets support
local capabilities = lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true

-- Snippets support
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
-- Lsp Symbols
fn.sign_define(
"LspDiagnosticsSignError",
{
texthl = "LspDiagnosticsSignError",
text = config.doom.lsp_error,
numhl = "LspDiagnosticsSignError"
}
)
fn.sign_define(
"LspDiagnosticsSignWarning",
{
texthl = "LspDiagnosticsSignWarning",
text = config.doom.lsp_warning,
numhl = "LspDiagnosticsSignWarning"
}
)
fn.sign_define(
"LspDiagnosticsSignHint",
{
texthl = "LspDiagnosticsSignHint",
text = config.doom.lsp_hint,
numhl = "LspDiagnosticsSignHint"
}
)
fn.sign_define(
"LspDiagnosticsSignInformation",
{
texthl = "LspDiagnosticsSignInformation",
text = config.doom.lsp_information,
numhl = "LspDiagnosticsSignInformation"
}
)

-- Lsp Symbols
vim.fn.sign_define('LspDiagnosticsSignError', {
texthl = 'LspDiagnosticsSignError',
text = config.doom.lsp_error,
numhl = 'LspDiagnosticsSignError',
})
vim.fn.sign_define('LspDiagnosticsSignWarning', {
texthl = 'LspDiagnosticsSignWarning',
text = config.doom.lsp_warning,
numhl = 'LspDiagnosticsSignWarning',
})
vim.fn.sign_define('LspDiagnosticsSignHint', {
texthl = 'LspDiagnosticsSignHint',
text = config.doom.lsp_hint,
numhl = 'LspDiagnosticsSignHint',
})
vim.fn.sign_define('LspDiagnosticsSignInformation', {
texthl = 'LspDiagnosticsSignInformation',
text = config.doom.lsp_information,
numhl = 'LspDiagnosticsSignInformation',
})
lsp.handlers["textDocument/publishDiagnostics"] =
lsp.with(
lsp.diagnostic.on_publish_diagnostics,
{
virtual_text = {
prefix = config.doom.lsp_virtual_text -- change this to whatever you want your diagnostic icons to be
}
}
)
-- symbols for autocomplete
lsp.protocol.CompletionItemKind = {
"  (Text) ",
"  (Method)",
"  (Function)",
"  (Constructor)",
" ﴲ (Field)",
"[] (Variable)",
"  (Class)",
" ﰮ (Interface)",
"  (Module)",
" 襁 (Property)",
"  (Unit)",
"  (Value)",
" 練 (Enum)",
"  (Keyword)",
"  (Snippet)",
"  (Color)",
"  (File)",
"  (Reference)",
"  (Folder)",
"  (EnumMember)",
" ﲀ (Constant)",
" ﳤ (Struct)",
"  (Event)",
"  (Operator)",
"  (TypeParameter)"
}

vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
virtual_text = {
prefix = config.doom.lsp_virtual_text, -- change this to whatever you want your diagnostic icons to be
},
}
)
-- symbols for autocomplete
vim.lsp.protocol.CompletionItemKind = {
'  (Text) ',
'  (Method)',
'  (Function)',
'  (Constructor)',
' ﴲ (Field)',
'[] (Variable)',
'  (Class)',
' ﰮ (Interface)',
'  (Module)',
' 襁 (Property)',
'  (Unit)',
'  (Value)',
' 練 (Enum)',
'  (Keyword)',
'  (Snippet)',
'  (Color)',
'  (File)',
'  (Reference)',
'  (Folder)',
'  (EnumMember)',
' ﲀ (Constant)',
' ﳤ (Struct)',
'  (Event)',
'  (Operator)',
'  (TypeParameter)',
}
-- suppress error messages from lang servers
vim.notify = function(msg, log_level, _opts)
if msg:match("exit code") then
return
end
if log_level == vim.log.levels.ERROR then
vim.api.nvim_err_writeln(msg)
else
vim.api.nvim_echo({{msg}}, true, {})
end
end
end

0 comments on commit 4f39029

Please sign in to comment.