mirror of
https://github.com/jessebot/dot_files.git
synced 2025-10-01 01:48:43 +00:00
print diagnostics in message area, not in hover menu
This commit is contained in:
parent
0f1498eac4
commit
7828ee7e86
3 changed files with 47 additions and 31 deletions
|
@ -28,11 +28,6 @@ vim.opt.termguicolors = true
|
|||
-- make searching case insensitive
|
||||
vim.opt.ignorecase = true
|
||||
|
||||
-- You will likely want to reduce updatetime which affects CursorHold
|
||||
-- note: this setting is global and should be set only once
|
||||
vim.o.updatetime = 25
|
||||
vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
|
||||
|
||||
-- indentation
|
||||
require('user.indent')
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ require('gitsigns').setup({
|
|||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
signcolumn = false, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = true, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
watch_gitdir = {
|
||||
|
@ -16,7 +16,7 @@ require('gitsigns').setup({
|
|||
follow_files = true
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||
|
|
|
@ -11,35 +11,34 @@ require("mason-lspconfig").setup {
|
|||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
-- all of the below are referenced from the neovim nvim-lspconfig repo
|
||||
-- ref: github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
|
||||
-- github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
|
||||
-- Setup the language servers so that they're available for our LSP client.
|
||||
local nvim_lsp = require('lspconfig')
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- ansible (may require npm install -g @ansible/ansible-language-server)
|
||||
nvim_lsp.ansiblels.setup{
|
||||
-- ansible
|
||||
lspconfig.ansiblels.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- bash (may require npm i -g bash-language-server)
|
||||
nvim_lsp.bashls.setup{
|
||||
-- bash
|
||||
lspconfig.bashls.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- docker (may require npm install -g dockerfile-language-server-nodejs)
|
||||
nvim_lsp.dockerls.setup{
|
||||
-- docker
|
||||
lspconfig.dockerls.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- json
|
||||
nvim_lsp.jsonls.setup {
|
||||
lspconfig.jsonls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
|
||||
-- lua (may require brew install lua-language-server)
|
||||
nvim_lsp.lua_ls.setup{
|
||||
-- lua
|
||||
lspconfig.lua_ls.setup{
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
|
@ -62,41 +61,41 @@ nvim_lsp.lua_ls.setup{
|
|||
},
|
||||
}
|
||||
|
||||
-- markdown (may require brew install marksman)
|
||||
nvim_lsp.marksman.setup{
|
||||
-- markdown
|
||||
lspconfig.marksman.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- python
|
||||
nvim_lsp.jedi_language_server.setup{
|
||||
lspconfig.jedi_language_server.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- python - ruff linting
|
||||
nvim_lsp.ruff_lsp.setup{}
|
||||
lspconfig.ruff_lsp.setup{}
|
||||
|
||||
-- terraform
|
||||
nvim_lsp.terraformls.setup{
|
||||
lspconfig.terraformls.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- Terraform linter that can act as lsp server.
|
||||
-- Installation ref: https://github.com/terraform-linters/tflint#installation
|
||||
-- nvim_lsp.tflint.setup{}
|
||||
lspconfig.tflint.setup{}
|
||||
|
||||
-- toml ( may require cargo install --features lsp --locked taplo-cli )
|
||||
nvim_lsp.taplo.setup{
|
||||
-- toml
|
||||
lspconfig.taplo.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- vim ( may require npm install -g vim-language-server )
|
||||
nvim_lsp.vimls.setup{
|
||||
-- vim -- will be removed when I finish converting everything to lua
|
||||
lspconfig.vimls.setup{
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- yaml - not sure if this is worth it yet
|
||||
-- github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#yamlls
|
||||
nvim_lsp.yamlls.setup {
|
||||
lspconfig.yamlls.setup {
|
||||
settings = {
|
||||
yaml = {
|
||||
schemas = {
|
||||
|
@ -114,3 +113,25 @@ for type, icon in pairs(signs) do
|
|||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
|
||||
-- Print diagnostics to message area
|
||||
function PrintDiagnostics(opts, bufnr, line_nr, client_id)
|
||||
bufnr = bufnr or 0
|
||||
line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
|
||||
opts = opts or {['lnum'] = line_nr}
|
||||
|
||||
local line_diagnostics = vim.diagnostic.get(bufnr, opts)
|
||||
if vim.tbl_isempty(line_diagnostics) then return end
|
||||
|
||||
local diagnostic_message = ""
|
||||
for i, diagnostic in ipairs(line_diagnostics) do
|
||||
diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
|
||||
print(diagnostic_message)
|
||||
if i ~= #line_diagnostics then
|
||||
diagnostic_message = diagnostic_message .. "\n"
|
||||
end
|
||||
end
|
||||
vim.api.nvim_echo({{diagnostic_message, "Normal"}}, false, {})
|
||||
end
|
||||
|
||||
vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue