This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress lang servers error messages (#69)
Particularly useful when using problematic language servers like `diagnosticls` and `efm`
- Loading branch information
Showing
3 changed files
with
100 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |