nvf time!
This commit is contained in:
parent
216904f679
commit
86977f4ecf
57 changed files with 4076 additions and 217 deletions
22
modules/editors/nvf/lua/misc/abbrev.lua
Normal file
22
modules/editors/nvf/lua/misc/abbrev.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
local cmd = vim.cmd
|
||||
|
||||
-- luacheck: ignore
|
||||
local abbreviations = {
|
||||
Wq = 'wq', -- keep making those typos
|
||||
WQ = 'wq',
|
||||
Wqa = 'wqa',
|
||||
W = 'w',
|
||||
Q = 'q',
|
||||
Qa = 'qa',
|
||||
Bd = 'bd',
|
||||
E = 'e',
|
||||
q1 = 'q!', -- this is for when I don't want to reach to shift
|
||||
qa1 = 'qa!',
|
||||
mk = 'mark', -- make marks faster
|
||||
st = 'sort', -- sort
|
||||
}
|
||||
|
||||
-- add more abbreviations
|
||||
for left, right in pairs(abbreviations) do
|
||||
cmd.cnoreabbrev(('%s %s'):format(left, right))
|
||||
end
|
13
modules/editors/nvf/lua/misc/autoread.lua
Normal file
13
modules/editors/nvf/lua/misc/autoread.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
-- If the cursor has been idle for some time, check if the current buffer
|
||||
-- has been modified externally. prompt the user to reload it if has.
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
|
||||
-- luacheck: ignore
|
||||
vim.opt_local.autoread = true
|
||||
vim.api.nvim_create_autocmd('CursorHold', {
|
||||
group = vim.api.nvim_create_augroup('Autoread', { clear = true }),
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.cmd('silent! checktime')
|
||||
end,
|
||||
})
|
68
modules/editors/nvf/lua/misc/declutter.lua
Normal file
68
modules/editors/nvf/lua/misc/declutter.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
-- luacheck: ignore
|
||||
vim.opt.spelllang:append('cjk') -- disable spellchecking for asian characters (VIM algorithm does not support it)
|
||||
|
||||
vim.opt.shortmess = {
|
||||
t = true, -- truncate file messages at start
|
||||
A = true, -- ignore annoying swap file messages
|
||||
o = true, -- file-read message overwrites previous
|
||||
O = true, -- file-read message overwrites previous
|
||||
T = true, -- truncate non-file messages in middle
|
||||
f = true, -- (file x of x) instead of just (x of x
|
||||
F = true, -- Don't give file info when editing a file, NOTE: this breaks autocommand messages
|
||||
s = true,
|
||||
c = true,
|
||||
W = true, -- Don't show [w] or written when writing
|
||||
}
|
||||
|
||||
-- Disable nvim intro
|
||||
vim.opt.shortmess:append('sI')
|
||||
|
||||
-- Some of those are already disasbled in the Neovim wrapper
|
||||
-- as configured by nvf. I'm just making sure they are disabled
|
||||
-- here as well.
|
||||
local disable_distribution_plugins = function()
|
||||
local disabled_built_ins = {
|
||||
'2html_plugin',
|
||||
'getscript',
|
||||
'getscriptPlugin',
|
||||
'gzip',
|
||||
'logipat',
|
||||
'matchit',
|
||||
'matchparen',
|
||||
'tar',
|
||||
'tarPlugin',
|
||||
'rrhelper',
|
||||
'spellfile_plugin',
|
||||
'vimball',
|
||||
'vimballPlugin',
|
||||
'zip',
|
||||
'zipPlugin',
|
||||
'tutor',
|
||||
'rplugin',
|
||||
'synmenu',
|
||||
'optwin',
|
||||
'compiler',
|
||||
'bugreport',
|
||||
'ftplugin',
|
||||
'netrw',
|
||||
'netrwPlugin',
|
||||
'netrwSettings',
|
||||
'netrwFileHandlers',
|
||||
-- "skip_ts_context_commentstring_module"
|
||||
}
|
||||
|
||||
for _, plugin in pairs(disabled_built_ins) do
|
||||
g['loaded_' .. plugin] = 1
|
||||
end
|
||||
end
|
||||
|
||||
-- https://github.com/neovim/neovim/issues/14090#issuecomment-1177933661
|
||||
-- vim.g.do_filetype_lua = 1
|
||||
-- vim.g.did_load_filetypes = 0
|
||||
|
||||
-- Neovim should not be able to load from those paths since
|
||||
-- we ultimately want to be able to *only* want the nvf config
|
||||
-- to be the effective one
|
||||
vim.opt.runtimepath:remove('/etc/xdg/nvim')
|
||||
vim.opt.runtimepath:remove('/etc/xdg/nvim/after')
|
||||
vim.opt.runtimepath:remove('/usr/share/vim/vimfiles')
|
22
modules/editors/nvf/lua/misc/diagnostics.lua
Normal file
22
modules/editors/nvf/lua/misc/diagnostics.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
-- Diagnostic settings:
|
||||
-- see: `:help vim.diagnostic.config`
|
||||
vim.diagnostic.config({
|
||||
update_in_insert = true,
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
virtual_lines = {
|
||||
only_current_line = true,
|
||||
spacing = 2,
|
||||
},
|
||||
|
||||
float = {
|
||||
focusable = false,
|
||||
style = 'minimal',
|
||||
border = 'rounded',
|
||||
source = 'always',
|
||||
header = '',
|
||||
prefix = '',
|
||||
},
|
||||
})
|
34
modules/editors/nvf/lua/misc/handlers.lua
Normal file
34
modules/editors/nvf/lua/misc/handlers.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
-- luacheck: ignore
|
||||
local float_options = {
|
||||
border = 'single',
|
||||
max_width = math.ceil(vim.api.nvim_win_get_width(0) * 0.6),
|
||||
max_height = math.ceil(vim.api.nvim_win_get_height(0) * 0.8),
|
||||
}
|
||||
|
||||
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = true,
|
||||
signs = false,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
vim.lsp.handlers['textDocument/show_line_diagnostics'] = vim.lsp.with(vim.lsp.handlers.hover, float_options)
|
||||
|
||||
-- Prevent show notification
|
||||
-- <https://github.com/neovim/neovim/issues/20457#issuecomment-1266782345>
|
||||
vim.lsp.handlers['textDocument/hover'] = function(_, result, ctx, config)
|
||||
config = config or float_options
|
||||
config.focus_id = ctx.method
|
||||
if not result then
|
||||
return
|
||||
end
|
||||
local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents)
|
||||
markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines)
|
||||
if vim.tbl_isempty(markdown_lines) then
|
||||
return
|
||||
end
|
||||
return vim.lsp.util.open_floating_preview(markdown_lines, 'markdown', config)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, float_options)
|
30
modules/editors/nvf/lua/misc/neovide.lua
Normal file
30
modules/editors/nvf/lua/misc/neovide.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
if vim.g.neovide then
|
||||
local vks = vim.keymap.set
|
||||
|
||||
vim.g.neovide_scale_factor = 1.0
|
||||
vim.g.minianimate_disable = true
|
||||
vim.g.neovide_window_blurred = true
|
||||
vim.g.neovide_transparency = 0.80
|
||||
vim.g.neovide_show_border = true
|
||||
vim.g.neovide_input_macos_alt_is_meta = true
|
||||
vim.g.neovide_cursor_animate_command_line = false -- noice incompat
|
||||
vim.g.neovide_cursor_smooth_blink = true
|
||||
vim.g.neovide_cursor_vfx_mode = 'ripple'
|
||||
|
||||
-- keymaps
|
||||
vks('v', '<D-c>', '"+y') -- Copy
|
||||
vks({ 'n', 'v' }, '<D-v>', '"+P') -- Paste
|
||||
vks({ 'i', 'c' }, '<D-v>', '<C-R>+') -- Paste
|
||||
vks('t', '<D-v>', [[<C-\><C-N>"+P]]) -- Paste
|
||||
vks('n', '<D-+>', function()
|
||||
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1
|
||||
end)
|
||||
vks('n', '<D-->', function()
|
||||
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor / 1.1
|
||||
end)
|
||||
vks({ 'n', 'v', 't', 'i' }, '<D-}>', [[<C-\><C-N><Cmd>tabnext<CR>]])
|
||||
vks({ 'n', 'v', 't', 'i' }, '<D-{>', [[<C-\><C-N><Cmd>tabprev<CR>]])
|
||||
vks({ 'n', 'v', 't', 'i' }, '<D-l>', [[<C-\><C-N><Cmd>tabnext #<CR>]])
|
||||
vks({ 'n', 'v', 't', 'i' }, '<D-t>', [[<C-\><C-N><Cmd>tabnew<CR>]])
|
||||
vks({ 'n', 'v', 't', 'i' }, '<D-w>', [[<C-\><C-N><Cmd>tabclose<CR>]])
|
||||
end
|
33
modules/editors/nvf/lua/misc/vscode.lua
Normal file
33
modules/editors/nvf/lua/misc/vscode.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
-- https://github.com/asvetliakov/vscode-neovim#normal-mode-control-keys
|
||||
-- available by default
|
||||
-- CTRL-a
|
||||
-- CTRL-b
|
||||
-- CTRL-c
|
||||
-- CTRL-d
|
||||
-- CTRL-e
|
||||
-- CTRL-f
|
||||
-- CTRL-i
|
||||
-- CTRL-o
|
||||
-- CTRL-r
|
||||
-- CTRL-u
|
||||
-- CTRL-v
|
||||
-- CTRL-w
|
||||
-- CTRL-x
|
||||
-- CTRL-y
|
||||
-- CTRL-]
|
||||
-- CTRL-j
|
||||
-- CTRL-k
|
||||
-- CTRL-l
|
||||
-- CTRL-h
|
||||
-- CTRL-/
|
||||
|
||||
if vim.g.vscode then
|
||||
vim.keymap.set('n', 'H', '<Cmd>Tabprevious<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('n', 'L', '<Cmd>Tabnext<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<Leader>p',
|
||||
"<<Cmd>call VSCodeNotify('workbench.action.quickOpen')<CR>>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue