gui zoom, misc plugin updates

This commit is contained in:
Amanda Graven 2022-08-15 15:05:12 +02:00
parent bba7ad4bc1
commit bbd2fb70f4
Signed by: amanda
GPG key ID: F747582C5608F4CB

View file

@ -74,6 +74,31 @@ if fn.executable('rg') then
o.grepformat = '%f:%l:%c:%m'
end
local zoom_notification = nil
--- "Zoom" by changing gui font size
--- @param delta integer
local function zoom(delta)
local size = fn.substitute(o.guifont, [[^.*:h\([^:]*\).*$]], [[\1]], '')
size = size + delta
local guifont = fn.substitute(o.guifont, [[:h\([^:]*\)]], ':h' .. size, '')
o.guifont = guifont
zoom_notification = vim.notify('Changing font size to ' .. size, vim.log.levels.INFO, {
title = 'Font size',
replace = zoom_notification,
hide_from_history = true,
})
end
local function zoom_in()
zoom(1)
end
local function zoom_out()
zoom(-1)
end
-- Convenience keybindings
do
-- which-key might not be available yet
@ -87,6 +112,9 @@ do
which_key.register { ['<A-l>'] = {'<C-w>l', 'Go to the right window'} }
which_key.register { ['<A-n>'] = {'<C-w>n', 'Go to the up window'} }
which_key.register { ['<A-e>'] = {'<C-w>e', 'Go to the down window'} }
which_key.register { ['+'] = {zoom_in, "Zoom in"} }
which_key.register { ['-'] = {zoom_out, "Zoom out"} }
end
end
@ -208,7 +236,7 @@ require'packer'.startup(function(use)
require'which-key'.register{['<Leader>s'] = {'<Cmd>ISwapWith<CR>','Swap'}}
end}
use 'bfredl/nvim-luadev' -- lua scratchpad
use 'vim-scripts/ReplaceWithRegister' -- gr replace with register
use 'tpope/vim-repeat'
use 'tpope/vim-sleuth'
-- spellsitter: syntax aware spellchecking
use {'lewis6991/spellsitter.nvim', config = function() require'spellsitter'.setup() end}
@ -218,7 +246,7 @@ require'packer'.startup(function(use)
vim.g['test#strategy'] = 'neovim'
end}
use {'julian/vim-textobj-variable-segment', requires = {'kana/vim-textobj-user'}}
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} -- TODO: upgrade parsers on update
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
use 'hrsh7th/vim-vsnip'
-- LSP --
@ -266,7 +294,7 @@ require'packer'.startup(function(use)
use 'junegunn/goyo.vim'
use 'kosayoda/nvim-lightbulb'
use {'https://git.sr.ht/~whynothugo/lsp_lines.nvim', config = function()
require'lsp_lines'.register_lsp_virtual_lines()
require'lsp_lines'.setup()
vim.diagnostic.config { virtual_text = false }
end}
use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function ()
@ -317,6 +345,7 @@ require'packer'.startup(function(use)
name = 'Telescope',
["<Space>"] = {'<Cmd>Telescope<CR>', 'List pickers'},
f = {'<Cmd>Telescope find_files<CR>', 'Files'},
F = {'<Cmd>Telescope file_browser<CR>', 'File browser'},
d = {'<Cmd>Telescope find_files find_command=fd,--type,d,-I<CR>', 'Directories'},
r = {'<Cmd>Telescope oldfiles<CR>', 'Recent files'},
g = {'<Cmd>Telescope live_grep<CR>', 'Grep'},
@ -326,6 +355,7 @@ require'packer'.startup(function(use)
p = {'<Cmd>Telescope project<CR>', 'Projects'},
s = {'<Cmd>Telescope lsp_dynamic_workspace_symbols<CR>', 'Symbols'},
n = {'<Cmd>Telescope notify<CR>', 'Notifications'},
m = {'<Cmd>Telescope man_pages<CR>', 'Man pages'},
[':'] = {'<Cmd>Telescope commands<CR>', 'Commands'},
}
}
@ -503,35 +533,36 @@ local capabilities = require'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.
--- Performs keymaps and other setup specific to buffers with LSP enabled
--- @param bufnr number
local function on_attach(_client, bufnr)
-- keybinding settings
local opts = { noremap = true, silent = true }
-- keybinding shorthand
local function bufmap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
require'which-key'.register({
g = {
d = {'<Cmd>lua vim.lsp.buf.definition()<CR>', 'Goto definition'},
D = {'<Cmd>lua vim.lsp.buf.implementation()<CR>', 'Goto implementation'},
a = {'<Cmd>lua vim.lsp.buf.code_action()<CR>', 'Code action'},
R = {'<Cmd>lua vim.lsp.buf.rename()<CR>', 'Rename'},
y = {'<Cmd>lua vim.lsp.buf.type_definition()<CR>', 'Type definition'},
d = {vim.lsp.buf.definition, 'Goto definition'},
D = {vim.lsp.buf.implementation, 'Goto implementation'},
a = {vim.lsp.buf.code_action, 'Code action'},
R = {vim.lsp.buf.rename, 'Rename'},
y = {vim.lsp.buf.type_definition, 'Type definition'},
},
[']'] = {
g = {'<Cmd>lua vim.diagnostic.goto_next()<CR>', 'Next diagnostic'},
e = {'<Cmd>lua vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR }<CR>', 'Next error'},
w = {'<Cmd>lua vim.diagnostic.goto_next { severity = vim.diagnostic.severity.WARN }<CR>', 'Next warning'},
q = {'<Cmd>lua vim.diagnostic.setqflist()<CR>', 'Quickfix diagnostics'},
g = {vim.diagnostic.goto_next, 'Next diagnostic'},
e = {function() vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR } end, 'Next error'},
w = {function() vim.diagnostic.goto_next { severity = vim.diagnostic.severity.WARN } end, 'Next warning'},
q = {vim.diagnostic.setqflist, 'Quickfix diagnostics'},
},
['['] = {
g = {'<Cmd>lua vim.diagnostic.goto_prev()<CR>', 'Previous diagnostic'},
e = {'<Cmd>lua vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR }<CR>', 'Previous error'},
w = {'<Cmd>lua vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.WARN }<CR>', 'Previous warning'},
g = {vim.diagnostic.goto_prev, 'Previous diagnostic'},
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'},
}
}, {buffer = bufnr})
-- Hover
bufmap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
bufmap('n', '<c-k>', '<Cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
bufmap('i', '<M-k>', '<Cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
require'which-key'.register({
['K'] = {vim.lsp.buf.hover, 'Documentation'},
['<C-k>'] = {vim.lsp.buf.signature_help, 'Function signature'},
}, {buffer = bufnr})
require'which-key'.register({
['<M-k'] = {vim.lsp.buf.signature_help, 'Function signature'}
}, {buffer = bufnr, mode = 'i'})
vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc'
end
@ -588,6 +619,8 @@ g.vim_markdown_math = 1
g.rust_recommended_style = 0
-- Format with rustfmt on save
g.rustfmt_autosave = 1
-- rustfmt is >=1.0
g.rustfmt_emit_files = 1
-- Use nigtly rustfmt for unstable settings
g.rustfmt_command = 'rustup run nightly rustfmt'
@ -725,11 +758,6 @@ require('nvim-tree').setup {
open_on_setup = true,
-- Match tree cwd to vim's cwd
update_cwd = true,
-- When a file is BufEnter'ed, focus it in the tree
update_focused_file = {
enable = true,
ignore_list = {'fugitive'}
}
}
vim.cmd'highlight NvimTreeOpenedFile guifg=NONE gui=italic'
vim.api.nvim_create_autocmd('ColorScheme', {
@ -738,7 +766,7 @@ vim.api.nvim_create_autocmd('ColorScheme', {
command = 'highlight NvimTreeOpenedFile guifg=NONE gui=italic'
})
require'which-key'.register{['<Leader>t'] = {'<Cmd>NvimTreeToggle<CR>', 'Nvim Tree'}}
require'which-key'.register{['<Leader>t'] = {'<Cmd>NvimTreeFindFileToggle<CR>', 'Nvim Tree'}}
---- treesitter ----
@ -748,7 +776,7 @@ require'nvim-treesitter.configs'.setup {
enable = true,
},
-- TODO; Pick list manually
ensure_installed = {'lua', 'html', 'c', 'cpp', 'nix', 'vim', 'rust'},
ensure_installed = {'lua', 'html', 'c', 'cpp', 'nix', 'vim', 'rust', 'markdown'},
highlight = { enable = true, disable = 'rust' },
incremental_selection = { enable = true },
}