gui zoom, misc plugin updates
This commit is contained in:
parent
bba7ad4bc1
commit
bbd2fb70f4
100
init.lua
100
init.lua
|
@ -74,19 +74,47 @@ if fn.executable('rg') then
|
||||||
o.grepformat = '%f:%l:%c:%m'
|
o.grepformat = '%f:%l:%c:%m'
|
||||||
end
|
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
|
-- Convenience keybindings
|
||||||
do
|
do
|
||||||
-- which-key might not be available yet
|
-- which-key might not be available yet
|
||||||
local ok, which_key = pcall(require, 'which-key')
|
local ok, which_key = pcall(require, 'which-key')
|
||||||
if ok then
|
if ok then
|
||||||
which_key.register{['<C-w>!'] = {'<Cmd>copen<CR>', 'Quickfix window'}}
|
which_key.register { ['<C-w>!'] = {'<Cmd>copen<CR>', 'Quickfix window'} }
|
||||||
which_key.register{['<F2>'] = {'<Cmd>set number! relativenumber!<CR>', 'Toggle relative numbers'}}
|
which_key.register { ['<F2>'] = {'<Cmd>set number! relativenumber!<CR>', 'Toggle relative numbers'} }
|
||||||
which_key.register{['<F3>'] = {'<Cmd>set number!<CR>', 'Toggle line numbers'}}
|
which_key.register { ['<F3>'] = {'<Cmd>set number!<CR>', 'Toggle line numbers'} }
|
||||||
|
|
||||||
which_key.register{['<A-h>'] = {'<C-w>h', 'Go to the left window'}}
|
which_key.register { ['<A-h>'] = {'<C-w>h', 'Go to the left window'} }
|
||||||
which_key.register{['<A-l>'] = {'<C-w>l', 'Go to the right window'}}
|
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-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 { ['<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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -208,7 +236,7 @@ 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 'vim-scripts/ReplaceWithRegister' -- gr replace with register
|
use 'tpope/vim-repeat'
|
||||||
use 'tpope/vim-sleuth'
|
use 'tpope/vim-sleuth'
|
||||||
-- spellsitter: syntax aware spellchecking
|
-- spellsitter: syntax aware spellchecking
|
||||||
use {'lewis6991/spellsitter.nvim', config = function() require'spellsitter'.setup() end}
|
use {'lewis6991/spellsitter.nvim', config = function() require'spellsitter'.setup() end}
|
||||||
|
@ -218,7 +246,7 @@ require'packer'.startup(function(use)
|
||||||
vim.g['test#strategy'] = 'neovim'
|
vim.g['test#strategy'] = 'neovim'
|
||||||
end}
|
end}
|
||||||
use {'julian/vim-textobj-variable-segment', requires = {'kana/vim-textobj-user'}}
|
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'
|
use 'hrsh7th/vim-vsnip'
|
||||||
|
|
||||||
-- LSP --
|
-- LSP --
|
||||||
|
@ -266,7 +294,7 @@ require'packer'.startup(function(use)
|
||||||
use 'junegunn/goyo.vim'
|
use 'junegunn/goyo.vim'
|
||||||
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'.register_lsp_virtual_lines()
|
require'lsp_lines'.setup()
|
||||||
vim.diagnostic.config { virtual_text = false }
|
vim.diagnostic.config { virtual_text = false }
|
||||||
end}
|
end}
|
||||||
use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function ()
|
use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function ()
|
||||||
|
@ -317,6 +345,7 @@ require'packer'.startup(function(use)
|
||||||
name = 'Telescope',
|
name = 'Telescope',
|
||||||
["<Space>"] = {'<Cmd>Telescope<CR>', 'List pickers'},
|
["<Space>"] = {'<Cmd>Telescope<CR>', 'List pickers'},
|
||||||
f = {'<Cmd>Telescope find_files<CR>', 'Files'},
|
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'},
|
d = {'<Cmd>Telescope find_files find_command=fd,--type,d,-I<CR>', 'Directories'},
|
||||||
r = {'<Cmd>Telescope oldfiles<CR>', 'Recent files'},
|
r = {'<Cmd>Telescope oldfiles<CR>', 'Recent files'},
|
||||||
g = {'<Cmd>Telescope live_grep<CR>', 'Grep'},
|
g = {'<Cmd>Telescope live_grep<CR>', 'Grep'},
|
||||||
|
@ -326,6 +355,7 @@ require'packer'.startup(function(use)
|
||||||
p = {'<Cmd>Telescope project<CR>', 'Projects'},
|
p = {'<Cmd>Telescope project<CR>', 'Projects'},
|
||||||
s = {'<Cmd>Telescope lsp_dynamic_workspace_symbols<CR>', 'Symbols'},
|
s = {'<Cmd>Telescope lsp_dynamic_workspace_symbols<CR>', 'Symbols'},
|
||||||
n = {'<Cmd>Telescope notify<CR>', 'Notifications'},
|
n = {'<Cmd>Telescope notify<CR>', 'Notifications'},
|
||||||
|
m = {'<Cmd>Telescope man_pages<CR>', 'Man pages'},
|
||||||
[':'] = {'<Cmd>Telescope commands<CR>', 'Commands'},
|
[':'] = {'<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
|
--- Performs keymaps and other setup specific to buffers with LSP enabled
|
||||||
--- @param bufnr number
|
--- @param bufnr number
|
||||||
local function on_attach(_client, bufnr)
|
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({
|
require'which-key'.register({
|
||||||
g = {
|
g = {
|
||||||
d = {'<Cmd>lua vim.lsp.buf.definition()<CR>', 'Goto definition'},
|
d = {vim.lsp.buf.definition, 'Goto definition'},
|
||||||
D = {'<Cmd>lua vim.lsp.buf.implementation()<CR>', 'Goto implementation'},
|
D = {vim.lsp.buf.implementation, 'Goto implementation'},
|
||||||
a = {'<Cmd>lua vim.lsp.buf.code_action()<CR>', 'Code action'},
|
a = {vim.lsp.buf.code_action, 'Code action'},
|
||||||
R = {'<Cmd>lua vim.lsp.buf.rename()<CR>', 'Rename'},
|
R = {vim.lsp.buf.rename, 'Rename'},
|
||||||
y = {'<Cmd>lua vim.lsp.buf.type_definition()<CR>', 'Type definition'},
|
y = {vim.lsp.buf.type_definition, 'Type definition'},
|
||||||
},
|
},
|
||||||
[']'] = {
|
[']'] = {
|
||||||
g = {'<Cmd>lua vim.diagnostic.goto_next()<CR>', 'Next diagnostic'},
|
g = {vim.diagnostic.goto_next, 'Next diagnostic'},
|
||||||
e = {'<Cmd>lua vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR }<CR>', 'Next error'},
|
e = {function() vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR } end, 'Next error'},
|
||||||
w = {'<Cmd>lua vim.diagnostic.goto_next { severity = vim.diagnostic.severity.WARN }<CR>', 'Next warning'},
|
w = {function() vim.diagnostic.goto_next { severity = vim.diagnostic.severity.WARN } end, 'Next warning'},
|
||||||
q = {'<Cmd>lua vim.diagnostic.setqflist()<CR>', 'Quickfix diagnostics'},
|
q = {vim.diagnostic.setqflist, 'Quickfix diagnostics'},
|
||||||
},
|
},
|
||||||
['['] = {
|
['['] = {
|
||||||
g = {'<Cmd>lua vim.diagnostic.goto_prev()<CR>', 'Previous diagnostic'},
|
g = {vim.diagnostic.goto_prev, 'Previous diagnostic'},
|
||||||
e = {'<Cmd>lua vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR }<CR>', 'Previous error'},
|
e = {function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR } end, 'Previous error'},
|
||||||
w = {'<Cmd>lua vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.WARN }<CR>', 'Previous warning'},
|
w = {function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.WARN } end, 'Previous warning'},
|
||||||
}
|
}
|
||||||
|
|
||||||
}, {buffer = bufnr})
|
}, {buffer = bufnr})
|
||||||
-- Hover
|
-- Hover
|
||||||
bufmap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
require'which-key'.register({
|
||||||
bufmap('n', '<c-k>', '<Cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
['K'] = {vim.lsp.buf.hover, 'Documentation'},
|
||||||
bufmap('i', '<M-k>', '<Cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
['<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'
|
vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc'
|
||||||
end
|
end
|
||||||
|
@ -588,6 +619,8 @@ g.vim_markdown_math = 1
|
||||||
g.rust_recommended_style = 0
|
g.rust_recommended_style = 0
|
||||||
-- Format with rustfmt on save
|
-- Format with rustfmt on save
|
||||||
g.rustfmt_autosave = 1
|
g.rustfmt_autosave = 1
|
||||||
|
-- rustfmt is >=1.0
|
||||||
|
g.rustfmt_emit_files = 1
|
||||||
-- Use nigtly rustfmt for unstable settings
|
-- Use nigtly rustfmt for unstable settings
|
||||||
g.rustfmt_command = 'rustup run nightly rustfmt'
|
g.rustfmt_command = 'rustup run nightly rustfmt'
|
||||||
|
|
||||||
|
@ -725,11 +758,6 @@ require('nvim-tree').setup {
|
||||||
open_on_setup = true,
|
open_on_setup = true,
|
||||||
-- Match tree cwd to vim's cwd
|
-- Match tree cwd to vim's cwd
|
||||||
update_cwd = true,
|
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.cmd'highlight NvimTreeOpenedFile guifg=NONE gui=italic'
|
||||||
vim.api.nvim_create_autocmd('ColorScheme', {
|
vim.api.nvim_create_autocmd('ColorScheme', {
|
||||||
|
@ -738,7 +766,7 @@ vim.api.nvim_create_autocmd('ColorScheme', {
|
||||||
command = 'highlight NvimTreeOpenedFile guifg=NONE gui=italic'
|
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 ----
|
---- treesitter ----
|
||||||
|
@ -748,7 +776,7 @@ require'nvim-treesitter.configs'.setup {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
-- TODO; Pick list manually
|
-- 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' },
|
highlight = { enable = true, disable = 'rust' },
|
||||||
incremental_selection = { enable = true },
|
incremental_selection = { enable = true },
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue