commit 1bb96539b078dd8d5e948de9cd2e0e309c260f8a
parent 18b9e6920aaeb7b0d89a96095a2c393988cae9d6
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date: Mon, 25 Jul 2022 11:43:54 +0200
lsp: add mapping to toggle lsp_lines
Diffstat:
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua
@@ -4,8 +4,8 @@ vim.cmd [[packadd nvim-lspconfig]]
vim.diagnostic.config {
virtual_text = false,
severity_sort = true,
- signs = false,
- virtual_lines = true
+ signs = { enable = true },
+ virtual_lines = false
}
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' })
@@ -62,13 +62,11 @@ local function on_attach(client, bufnr)
buf_set_keymap('<Leader>a', vim.lsp.buf.code_action)
buf_set_keymap('[d', vim.diagnostic.goto_prev)
buf_set_keymap(']d', vim.diagnostic.goto_next)
- buf_set_keymap('<Leader>l', vim.diagnostic.setloclist)
buf_set_keymap('<Leader>q', vim.diagnostic.setqflist)
buf_set_keymap('<Leader>=', function() vim.lsp.buf.format { async = true } end)
- buf_set_keymap('gR', require"telescope.builtin".lsp_references)
- buf_set_keymap('<Leader>s', require"telescope.builtin".lsp_dynamic_workspace_symbols)
+ buf_set_keymap('gR', require "telescope.builtin".lsp_references)
+ buf_set_keymap('<Leader>s', require "telescope.builtin".lsp_dynamic_workspace_symbols)
- -- I always have telecope on, but we never know
local f = nil
for _, path in pairs(vim.lsp.buf.list_workspace_folders()) do
if #path > 0 and path ~= vim.fn.expand("$HOME") then
@@ -76,25 +74,25 @@ local function on_attach(client, bufnr)
break
end
end
- if pcall(require, 'telescope') and f then
- buf_set_keymap('<Leader>e', function() require"telescope.builtin".fd{ cwd = f } end)
- end
+ buf_set_keymap('<Leader>e', function() require "telescope.builtin".fd { cwd = f } end)
-- LSP lines setup
+ buf_set_keymap('<Leader>l', require("lsp_lines").toggle)
set_autocmd("InsertEnter", function()
+ -- Force off lsp_lines on enter
vim.diagnostic.config { virtual_lines = false }
end)
- set_autocmd("InsertLeave", function()
- vim.diagnostic.config { virtual_lines = true }
- end)
if client.supports_method('textDocument/documentHighlight') then
set_autocmd("CursorHold", vim.lsp.buf.document_highlight)
set_autocmd("CursorMoved", vim.lsp.buf.clear_references)
end
- -- vim.api.nvim_buf_call(bufnr, function()
- -- vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.diagnostic.open_float, 0, {focusable = false, scope = 'cursor'})]]
- -- end)
+
+ set_autocmd("CursorHold", function()
+ if not vim.diagnostic.config().virtual_lines then
+ vim.diagnostic.open_float { focusable = false, scope = 'line' }
+ end
+ end)
end
-- TexLab and LTeX things
diff --git a/lua/neogit-config.lua b/lua/neogit-config.lua
@@ -5,7 +5,7 @@ gitsigns.setup {
current_line_blame_opts = {
delay = 1000,
},
- sign_priority = 1000,
+ sign_priority = 1,
on_attach = function(bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-S>', ':Gitsigns stage_hunk<CR>', { silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'v', '<C-S>', ':Gitsigns stage_hunk<CR>', { silent = true })