Navic, projectconfig, term shift-esc, zoom notif fix, diagnostic display

This commit is contained in:
Amanda Graven 2023-04-12 10:27:14 +02:00
parent caa187ca9c
commit 443d2b8b94
No known key found for this signature in database
GPG key ID: 79A68E63058F3BA1

View file

@ -54,6 +54,7 @@ o.tabstop = 4 -- A physical tab is 4 characters wide
o.shiftwidth = 4 -- A unit of indentention is 4 levels wide o.shiftwidth = 4 -- A unit of indentention is 4 levels wide
o.wrapmargin = 0 -- Disable hard line wrapping o.wrapmargin = 0 -- Disable hard line wrapping
o.textwidth = 0 -- Comments lines should wrap at 100 chars o.textwidth = 0 -- Comments lines should wrap at 100 chars
o.laststatus = 3
-- Set <Leader> key -- Set <Leader> key
g.mapleader = ' ' g.mapleader = ' '
vim.cmd 'filetype plugin indent on' vim.cmd 'filetype plugin indent on'
@ -91,7 +92,7 @@ local function zoom(delta)
hide_from_history = true, hide_from_history = true,
} }
if zoom_notification ~= nil then if zoom_notification ~= nil then
properties.replace = zoom_notification properties.replace = zoom_notification.id
end end
zoom_notification = vim.notify('Changing font size to ' .. size, vim.log.levels.INFO, properties) zoom_notification = vim.notify('Changing font size to ' .. size, vim.log.levels.INFO, properties)
end end
@ -123,6 +124,7 @@ do
if ok then if ok then
notify.dismiss{} notify.dismiss{}
end end
vim.lsp.buf.clear_references()
vim.cmd('nohlsearch|diffupdate|normal! <C-l>') vim.cmd('nohlsearch|diffupdate|normal! <C-l>')
end, 'Clear'} } end, 'Clear'} }
@ -140,6 +142,9 @@ do
end end
end end
end end
vim.cmd [[
tnoremap <S-Esc> <C-\><C-n>'
]]
-- Commands -- Commands
vim.cmd [[ vim.cmd [[
@ -187,7 +192,7 @@ vim.diagnostic.config {
-- Configure underlining diagnostics -- Configure underlining diagnostics
underline = { underline = {
-- Only underline warnings and up -- Only underline warnings and up
severity = vim.diagnostic.severity.WARN severity = { min = vim.diagnostic.severity.WARN }
} }
} }
@ -257,6 +262,12 @@ require'packer'.startup(function(use)
require'which-key'.register{['<Leader>s'] = {'<Cmd>ISwapWith<CR>','Swap'}} require'which-key'.register{['<Leader>s'] = {'<Cmd>ISwapWith<CR>','Swap'}}
end} end}
use 'bfredl/nvim-luadev' -- lua scratchpad use 'bfredl/nvim-luadev' -- lua scratchpad
use {'windwp/nvim-projectconfig', config = function ()
require'nvim-projectconfig'.setup {
-- Load project configuration when changing directory
autocmd = true,
}
end}
use 'tpope/vim-repeat' use 'tpope/vim-repeat'
use 'tpope/vim-sleuth' use 'tpope/vim-sleuth'
-- spellsitter: syntax aware spellchecking -- spellsitter: syntax aware spellchecking
@ -288,12 +299,17 @@ require'packer'.startup(function(use)
} }
} }
end} end}
use 'SmiteshP/nvim-navic'
use {'utilyre/barbecue.nvim', config = function ()
require'barbecue'.setup()
end}
-- UI elements -- -- UI elements --
use 'vim-airline/vim-airline' use 'vim-airline/vim-airline'
use 'vim-airline/vim-airline-themes' use 'vim-airline/vim-airline-themes'
use 'romgrk/barbar.nvim' use 'romgrk/barbar.nvim'
use {'MattesGroeger/vim-bookmarks', config = function() use {'MattesGroeger/vim-bookmarks', config = function()
vim.g.bookmark_no_default_key_mappings = 1
vim.g.bookmark_save_per_working_dir = 1 vim.g.bookmark_save_per_working_dir = 1
end} end}
use {'mfussenegger/nvim-dap', config = function() use {'mfussenegger/nvim-dap', config = function()
@ -444,7 +460,14 @@ require'packer'.startup(function(use)
use 'kosayoda/nvim-lightbulb' use 'kosayoda/nvim-lightbulb'
use {'https://git.sr.ht/~whynothugo/lsp_lines.nvim', config = function() use {'https://git.sr.ht/~whynothugo/lsp_lines.nvim', config = function()
require'lsp_lines'.setup() require'lsp_lines'.setup()
vim.diagnostic.config { virtual_text = false } vim.diagnostic.config {
virtual_text = {
severity = { min = vim.diagnostic.severity.WARN },
},
virtual_lines = {
only_current_line = true,
}
}
end} end}
use {'williamboman/mason.nvim', config = function() use {'williamboman/mason.nvim', config = function()
require'mason'.setup() require'mason'.setup()
@ -645,6 +668,7 @@ require'gitsigns'.setup {
S = {gitsigns.stage_buffer, 'Stage buffer'}, S = {gitsigns.stage_buffer, 'Stage buffer'},
u = {gitsigns.unstage_hunk, 'Unstage hunk'}, u = {gitsigns.unstage_hunk, 'Unstage hunk'},
U = {gitsigns.unstage_buffer, 'Unstage buffer'}, U = {gitsigns.unstage_buffer, 'Unstage buffer'},
r = {gitsigns.reset_hunk, 'Reset hunk'},
v = {gitsigns.select_hunk, 'Visual select hunk'}, v = {gitsigns.select_hunk, 'Visual select hunk'},
d = {gitsigns.toggle_deleted, 'Toggle deleted lines'}, d = {gitsigns.toggle_deleted, 'Toggle deleted lines'},
w = {gitsigns.toggle_word_diff, 'Toggle word diffs'}, w = {gitsigns.toggle_word_diff, 'Toggle word diffs'},
@ -732,7 +756,7 @@ local capabilities = require'cmp_nvim_lsp'.default_capabilities()
--- Performs keymaps and other setup specific to buffers with LSP enabled --- Performs keymaps and other setup specific to buffers with LSP enabled
--- @param bufnr number --- @param bufnr number
--- @diagnostic disable-next-line: unused-local --- @diagnostic disable-next-line: unused-local
local function on_attach(_client, bufnr) local function on_attach(client, bufnr)
require'which-key'.register({ require'which-key'.register({
g = { g = {
@ -752,8 +776,8 @@ local function on_attach(_client, bufnr)
g = {vim.diagnostic.goto_prev, 'Previous diagnostic'}, g = {vim.diagnostic.goto_prev, 'Previous diagnostic'},
e = {function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR } end, 'Previous error'}, e = {function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR } end, 'Previous error'},
w = {function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.WARN } end, 'Previous warning'}, w = {function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.WARN } end, 'Previous warning'},
} },
['<C-h>'] = {vim.lsp.buf.document_highlight, 'Highlight object under cursor'},
}, {buffer = bufnr}) }, {buffer = bufnr})
-- Hover -- Hover
require'which-key'.register({ require'which-key'.register({
@ -765,6 +789,10 @@ local function on_attach(_client, bufnr)
}, {buffer = bufnr, mode = 'i'}) }, {buffer = bufnr, mode = 'i'})
vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc' vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc'
require'nvim-navic'.attach(client, bufnr)
au('CursorMoved', { callback = vim.lsp.buf.clear_references, buffer = bufnr, })
end end
-- Enable language servers -- Enable language servers
@ -773,9 +801,6 @@ local default = {
on_attach = on_attach, on_attach = on_attach,
} }
local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, 'lua/?.lua')
table.insert(runtime_path, 'lua/?/init.lua')
require'lspconfig'.lua_ls.setup { require'lspconfig'.lua_ls.setup {
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
@ -783,13 +808,13 @@ require'lspconfig'.lua_ls.setup {
Lua = { Lua = {
runtime = { runtime = {
version = 'LuaJIT', version = 'LuaJIT',
path = runtime_path,
}, },
diagnostics = { diagnostics = {
globals = {'vim'}, globals = {'vim'},
}, },
workspace = { workspace = {
library = vim.api.nvim_get_runtime_file('', true), library = vim.api.nvim_get_runtime_file('', true),
checkThirdParty = false,
}, },
telemetry = { telemetry = {
enable = false, enable = false,
@ -952,6 +977,8 @@ require('nvim-tree').setup {
highlight_opened_files = 'name', highlight_opened_files = 'name',
-- Don't hightlight files as spceial -- Don't hightlight files as spceial
special_files = {}, special_files = {},
-- Combine nested folders with only one child
group_empty = true,
-- Icon settings -- Icon settings
icons = { icons = {
-- Hide git attribute icons -- Hide git attribute icons
@ -986,7 +1013,7 @@ require'nvim-treesitter.configs'.setup {
autotag = { autotag = {
enable = true, enable = true,
}, },
ensure_installed = {'lua', 'html', 'c', 'cpp', 'nix', 'vim', 'rust'}, ensure_installed = {'lua', 'html', 'c', 'cpp', 'nix', 'vim', 'rust', 'bash', 'markdown', 'java', 'markdown_inline'},
highlight = { enable = true, disable = 'rust' }, highlight = { enable = true, disable = 'rust' },
incremental_selection = { enable = true }, incremental_selection = { enable = true },
} }