Last active
December 9, 2022 18:21
-
-
Save phelipetls/0aeb9f4aca9af25d9f45ee56e0c5a340 to your computer and use it in GitHub Desktop.
Revisions
-
phelipetls revised this gist
May 1, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,8 @@ local parse_diagnostics = function(diagnostics) return items end -- redefine unwanted callbacks to be an empty function -- notice that I keep `vim.lsp.util.buf_diagnostics_underline()` vim.lsp.util.buf_diagnostics_signs = function() return end vim.lsp.util.buf_diagnostics_virtual_text = function() return end -
phelipetls revised this gist
May 1, 2020 . 2 changed files with 15 additions and 34 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,15 @@ local severity_map = { "E", "W", "I", "H" } local parse_diagnostics = function(diagnostics) if not diagnostics then return end local items = {} for _, diagnostic in ipairs(diagnostics) do local fname = vim.fn.bufname() local position = diagnostic.range.start local severity = diagnostic.severity table.insert(items, { filename = fname, type = severity_map[severity], lnum = position.line + 1, col = position.character + 1, text = diagnostic.message:gsub("\r", ""):gsub("\n", " ") @@ -13,30 +18,17 @@ local parse_diagnostics = function(diagnostics) return items end vim.lsp.util.buf_diagnostics_signs = function() return end vim.lsp.util.buf_diagnostics_virtual_text = function() return end update_diagnostics_loclist = function() bufnr = vim.fn.bufnr() diagnostics = vim.lsp.util.diagnostics_by_buf[bufnr] items = parse_diagnostics(diagnostics) vim.lsp.util.set_loclist(items) vim.api.nvim_command("doautocmd QuickFixCmdPost") end vim.api.nvim_command [[autocmd! User LspDiagnosticsChanged lua update_diagnostics_loclist()]] This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +0,0 @@ -
phelipetls revised this gist
Apr 11, 2020 . 2 changed files with 18 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,4 @@ local parse_diagnostics = function(diagnostics) local items = {} for _, diagnostic in ipairs(diagnostics) do local fname = vim.uri_to_fname(diagnostic.uri) @@ -34,26 +30,13 @@ local diagnostics_quickfix = function(_, _, result, _) end local items = parse_diagnostics(diagnostics) vim.lsp.util.set_loclist(items) local ll = vim.fn.getloclist(bufnr) -- when errors are fixed, close loclist if ll and #ll == 0 then vim.api.nvim_command("lclose") end vim.api.nvim_command("autocmd! BufWritePost <buffer> Lwindow") end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ function! Lwindow() " open lwindow, if not empty try lwindow " ignore error if there isn't one catch /E776/ return endtry endfunction command! Lwindow call Lwindow() -
phelipetls revised this gist
Apr 9, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,7 @@ end -- set as callback to all servers vim.lsp.callbacks["textDocument/publishDiagnostics"] = diagnostics_quickfix -- set as callback to a specific lsp server nvim_lsp.tsserver.setup{ callbacks = { ["textDocument/publishDiagnostics"] = diagnostics_quickfix }; } -
phelipetls revised this gist
Apr 9, 2020 . 1 changed file with 17 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ local parse_diagnostics = function(diagnostics) -- parse diagnostics into a table to be passed -- to setqflist function of vim -- -- check out :help setqflist local items = {} for _, diagnostic in ipairs(diagnostics) do local fname = vim.uri_to_fname(diagnostic.uri) @@ -30,6 +34,10 @@ local diagnostics_quickfix = function(_, _, result, _) end local items = parse_diagnostics(diagnostics) -- equivalent to vim.fn.setqflist({}, ' ', { title = "Language Server", items = items } ) -- :help setqflist -- :help vim.fn vim.lsp.util.set_qflist(items) -- when errors are fixed, close qflist @@ -40,4 +48,12 @@ local diagnostics_quickfix = function(_, _, result, _) -- open quick fix list on save vim.api.nvim_command("autocmd! BufWritePost <buffer> doautocmd QuickFixCmdPost") end -- set as callback to all servers vim.lsp.callbacks["textDocument/publishDiagnostics"] = diagnostics_quickfix -- set callback to a specific lsp server nvim_lsp.tsserver.setup{ callbacks = { ["textDocument/publishDiagnostics"] = diagnostics_quickfix }; } -
phelipetls created this gist
Apr 9, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ local parse_diagnostics = function(diagnostics) local items = {} for _, diagnostic in ipairs(diagnostics) do local fname = vim.uri_to_fname(diagnostic.uri) local position = diagnostic.range.start table.insert(items, { filename = fname, lnum = position.line + 1, col = position.character + 1, text = diagnostic.message:gsub("\r", ""):gsub("\n", " ") }) end return items end local diagnostics_quickfix = function(_, _, result, _) if not result then return end local uri = result.uri local bufnr = vim.uri_to_bufnr(uri) if not bufnr then err_message("LSP.publishDiagnostics: Couldn't find buffer for ", uri) return end local diagnostics = result.diagnostics for _, v in ipairs(diagnostics) do v.uri = v.uri or result.uri end local items = parse_diagnostics(diagnostics) vim.lsp.util.set_qflist(items) -- when errors are fixed, close qflist local qf = vim.fn.getqflist({["size"] = 0}) if qf["size"] == nil or qf["size"] == 0 then vim.api.nvim_command("cclose") end -- open quick fix list on save vim.api.nvim_command("autocmd! BufWritePost <buffer> doautocmd QuickFixCmdPost") end