chore(nvim): clean config
This commit is contained in:
@@ -1,31 +1,13 @@
|
|||||||
-- Lazy bootstrap
|
local lazy = require('BluePlum.lazy').bootstrap()
|
||||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
|
||||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|
||||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
|
||||||
local out = vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
|
|
||||||
if vim.v.shell_error ~= 0 then
|
|
||||||
vim.api.nvim_echo({
|
|
||||||
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
|
|
||||||
{ out, 'WarningMsg' },
|
|
||||||
{ '\nPress any key to exit...' },
|
|
||||||
}, true, {})
|
|
||||||
vim.fn.getchar()
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
require('BluePlum.set')
|
require('BluePlum')
|
||||||
require('BluePlum.keymap')
|
|
||||||
require('BluePlum.neovide')
|
|
||||||
|
|
||||||
require('lazy').setup({
|
if lazy then
|
||||||
-- Plugins
|
lazy.setup({
|
||||||
spec = {
|
spec = {
|
||||||
{ import = 'plugins' },
|
{ import = 'plugins' },
|
||||||
},
|
},
|
||||||
checker = { enabled = false },
|
checker = { enabled = false },
|
||||||
change_detection = { notify = false },
|
change_detection = { notify = false },
|
||||||
})
|
})
|
||||||
|
end
|
||||||
require('BluePlum.input')
|
|
||||||
|
|||||||
22
.config/nvim/lua/BluePlum/commands.lua
Normal file
22
.config/nvim/lua/BluePlum/commands.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
vim.api.nvim_create_user_command('Dot', 'edit ~/.config/nvim', {})
|
||||||
|
|
||||||
|
vim.cmd.cnoreabbrev('Git', 'GIt')
|
||||||
|
vim.api.nvim_create_user_command('GIt', function(ctx)
|
||||||
|
local subcommand = ctx.fargs[1]
|
||||||
|
if subcommand == 'log' then
|
||||||
|
local argv = table.concat({
|
||||||
|
'log',
|
||||||
|
'--graph',
|
||||||
|
'--abbrev-commit',
|
||||||
|
'--decorate',
|
||||||
|
}, ' ')
|
||||||
|
|
||||||
|
local sliced = vim.list_slice(ctx.fargs, 2)
|
||||||
|
vim.cmd.Git(argv .. ' ' .. table.concat(sliced, ' '))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd.Git(table.concat(ctx.fargs, ' '))
|
||||||
|
end, {
|
||||||
|
nargs = '+',
|
||||||
|
})
|
||||||
3
.config/nvim/lua/BluePlum/init.lua
Normal file
3
.config/nvim/lua/BluePlum/init.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
require('BluePlum.set')
|
||||||
|
require('BluePlum.keymap')
|
||||||
|
require('BluePlum.commands')
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
local M = {
|
|
||||||
interupt = false,
|
|
||||||
}
|
|
||||||
|
|
||||||
M.Keys = {
|
|
||||||
enter = '<CR>',
|
|
||||||
tab = '<Tab>',
|
|
||||||
backspace = '<BS>',
|
|
||||||
escape = '<Esc>',
|
|
||||||
|
|
||||||
-- if await_key().is_arrow
|
|
||||||
-- if key == Keys.left
|
|
||||||
left = { is_arrow = true, this = '<Left>' },
|
|
||||||
right = { is_arrow = true, this = '<Right>' },
|
|
||||||
up = { is_arrow = true, this = '<Up>' },
|
|
||||||
down = { is_arrow = true, this = '<Down>' },
|
|
||||||
}
|
|
||||||
|
|
||||||
function M.await_key()
|
|
||||||
-- local char = vim.fn.getchar()
|
|
||||||
local char = vim.fn.getchar()
|
|
||||||
local num = vim.fn.nr2char(char)
|
|
||||||
local key = vim.fn.keytrans(num)
|
|
||||||
-- vim.print(char, num, key, key == '<BS>')
|
|
||||||
|
|
||||||
-- Some special keys work weird..
|
|
||||||
local is_key = function(key)
|
|
||||||
return pcall(function(char)
|
|
||||||
if vim.fn.keytrans(char) ~= key then
|
|
||||||
error()
|
|
||||||
end
|
|
||||||
end, char)
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_key('<BS>') then
|
|
||||||
return M.Keys.backspace
|
|
||||||
elseif is_key('<Left>') then
|
|
||||||
return M.Keys.left
|
|
||||||
elseif is_key('<Right>') then
|
|
||||||
return M.Keys.right
|
|
||||||
elseif is_key('<Up>') then
|
|
||||||
return M.Keys.up
|
|
||||||
elseif is_key('<Down>') then
|
|
||||||
return M.Keys.down
|
|
||||||
elseif key == '<Space>' then
|
|
||||||
return ' '
|
|
||||||
elseif key == '<Lt>' then
|
|
||||||
return '<'
|
|
||||||
elseif key == '<Gt>' then
|
|
||||||
return '>'
|
|
||||||
end
|
|
||||||
|
|
||||||
return key
|
|
||||||
end
|
|
||||||
|
|
||||||
-- vim.print(vim.fn.getcompletion('ech', 'command'))
|
|
||||||
-- vim.fn.getchar()
|
|
||||||
|
|
||||||
local function refresh_completions(pattern, kind)
|
|
||||||
local completions = vim.fn.getcompletion(pattern, kind)
|
|
||||||
|
|
||||||
if #completions > 25 then
|
|
||||||
local new = {}
|
|
||||||
for i = 1, 25 do
|
|
||||||
new[i] = completions[i]
|
|
||||||
end
|
|
||||||
new[#new + 1] = '...' -- Append truncation indicator
|
|
||||||
return new
|
|
||||||
end
|
|
||||||
|
|
||||||
return completions
|
|
||||||
end
|
|
||||||
|
|
||||||
local function format_completions(completions)
|
|
||||||
local formatted = { { '{', 'Normal' } }
|
|
||||||
for i = 1, #completions do
|
|
||||||
table.insert(formatted, { completions[i], i == 1 and 'CursorLineNr' or 'Normal' })
|
|
||||||
if i ~= #completions then
|
|
||||||
table.insert(formatted, { ', ', 'Normal' })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(formatted, { '}', 'Normal' })
|
|
||||||
return formatted
|
|
||||||
end
|
|
||||||
|
|
||||||
local function input(prompt, default, completion)
|
|
||||||
vim.validate({
|
|
||||||
prompt = { prompt, 'table' },
|
|
||||||
default = { default, { 'string', 'nil' } },
|
|
||||||
completion = { completion, { 'string', 'nil' } },
|
|
||||||
})
|
|
||||||
local using_default = default ~= nil
|
|
||||||
local typed = default or ''
|
|
||||||
|
|
||||||
local completions = {}
|
|
||||||
|
|
||||||
local cursor = 0
|
|
||||||
|
|
||||||
while true do
|
|
||||||
if completion ~= nil then
|
|
||||||
completions = refresh_completions(typed, completion)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.cmd('echo | redraw')
|
|
||||||
vim.api.nvim_echo({
|
|
||||||
unpack(prompt),
|
|
||||||
{ string.sub(typed, 0, cursor), using_default and 'Visual' or 'Normal' },
|
|
||||||
cursor == #typed and { '█', 'CursorLineNr' } or { string.sub(typed, cursor + 1, cursor + 1), 'Search' },
|
|
||||||
{ string.sub(typed, cursor + 2), 'Normal' },
|
|
||||||
unpack(#completions > 0 and format_completions(completions) or {}),
|
|
||||||
}, false, {})
|
|
||||||
local input = M.await_key()
|
|
||||||
|
|
||||||
if input == M.Keys.enter or input == M.Keys.escape then
|
|
||||||
vim.cmd('echo | redraw')
|
|
||||||
return input == M.Keys.enter, typed
|
|
||||||
elseif input == M.Keys.backspace then
|
|
||||||
if cursor <= 0 then
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
typed = string.sub(typed, 0, cursor - 1) .. string.sub(typed, cursor + 1)
|
|
||||||
cursor = cursor - 1
|
|
||||||
goto continue
|
|
||||||
elseif input.is_arrow then
|
|
||||||
if input == M.Keys.left then
|
|
||||||
if cursor > 0 then
|
|
||||||
cursor = cursor - 1
|
|
||||||
end
|
|
||||||
elseif input == M.Keys.right then
|
|
||||||
if cursor < #typed then
|
|
||||||
cursor = cursor + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- vim.api.nvim_win_set_cursor(0, { 1, 10 })
|
|
||||||
goto continue
|
|
||||||
elseif input == M.Keys.tab then
|
|
||||||
if #completions == 0 then
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
cursor = #typed
|
|
||||||
|
|
||||||
local insert = completions[1]
|
|
||||||
local offset = #typed
|
|
||||||
|
|
||||||
-- Find the largest overlapping slice
|
|
||||||
while offset > 0 and not vim.startswith(insert, string.sub(typed, -offset)) do
|
|
||||||
offset = offset - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Replace `typed` with the completion
|
|
||||||
typed = string.sub(typed, 1, #typed - offset) .. insert .. ' '
|
|
||||||
cursor = #typed
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
|
|
||||||
typed = string.sub(typed, 0, cursor) .. input .. string.sub(typed, cursor + 1)
|
|
||||||
cursor = cursor + 1
|
|
||||||
|
|
||||||
::continue::
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Safe wrapper for hiding the cursor (also captures <C-c>)
|
|
||||||
function M.input(prompt, default, completion)
|
|
||||||
local hl = vim.api.nvim_get_hl(0, { name = 'Cursor' })
|
|
||||||
|
|
||||||
hl.blend = 100
|
|
||||||
vim.api.nvim_set_hl(0, 'Cursor', hl)
|
|
||||||
|
|
||||||
-- local result, success, typed = pcall(input, prompt, defaut, completion)
|
|
||||||
local success, typed = input(prompt, default, completion)
|
|
||||||
vim.cmd('echo | redraw')
|
|
||||||
|
|
||||||
hl.blend = 0
|
|
||||||
vim.api.nvim_set_hl(0, 'Cursor', hl)
|
|
||||||
|
|
||||||
return success, typed, not result
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param opts? table
|
|
||||||
---@param on_confirm function
|
|
||||||
vim.ui.input = function(opts, on_confirm)
|
|
||||||
vim.validate({
|
|
||||||
opts = { opts, 'table' },
|
|
||||||
on_confirm = { on_confirm, 'function' },
|
|
||||||
})
|
|
||||||
|
|
||||||
opts = opts or {}
|
|
||||||
on_confirm = on_confirm or function() end
|
|
||||||
|
|
||||||
vim.validate({
|
|
||||||
-- Also supports list of HlGroup tuples
|
|
||||||
prompt = { opts.prompt, { 'table', 'string', 'nil' } },
|
|
||||||
|
|
||||||
default = { opts.default, { 'string', 'nil' } },
|
|
||||||
completion = { opts.completion, { 'string', 'nil' } },
|
|
||||||
|
|
||||||
highlight = {
|
|
||||||
opts.highlight,
|
|
||||||
function(it)
|
|
||||||
return it == nil
|
|
||||||
end,
|
|
||||||
'nil (not supported)',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local prompt = opts.prompt or { { 'Enter input > ', 'Question' } }
|
|
||||||
if type(prompt) == 'string' then
|
|
||||||
-- Strip invalid characters
|
|
||||||
prompt = vim.trim(prompt)
|
|
||||||
|
|
||||||
local is_alpha = function(char)
|
|
||||||
local num = vim.fn.char2nr(char)
|
|
||||||
return (num >= 65 and num <= 90) or (num >= 97 and num <= 122)
|
|
||||||
end
|
|
||||||
|
|
||||||
local last = string.sub(prompt, #prompt)
|
|
||||||
while not is_alpha(last) do
|
|
||||||
prompt = string.sub(prompt, 0, #prompt - 1)
|
|
||||||
prompt = vim.trim(prompt)
|
|
||||||
last = string.sub(prompt, #prompt)
|
|
||||||
end
|
|
||||||
|
|
||||||
prompt = { { prompt .. ' > ', 'Question' } }
|
|
||||||
end
|
|
||||||
|
|
||||||
local finished, typed, interrupted = M.input(prompt, opts.default, opts.completion)
|
|
||||||
if interrupted then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
on_confirm(finished and typed or nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- vim.ui.input({ completion = 'cmdline' }, function(a)
|
|
||||||
-- vim.print(a)
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- vim.keymap.set('n', ';', function()
|
|
||||||
-- vim.ui.input({ prompt = { { ':', 'Normal' } }, completion = 'cmdline' }, function(command)
|
|
||||||
-- vim.print(command)
|
|
||||||
-- if command then
|
|
||||||
-- vim.cmd(command)
|
|
||||||
-- end
|
|
||||||
-- end)
|
|
||||||
-- end)
|
|
||||||
-- add cmdheight to the input function
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,93 +1,87 @@
|
|||||||
local set = vim.keymap.set
|
--- Defaults to `{'n'}`
|
||||||
|
--- @alias Mode 'n'|'v'|'Q'|'t'|'i'|'c'
|
||||||
|
--- @alias Mapping string|fun(): nil
|
||||||
|
|
||||||
set('i', '<M-Up>', '<ESC>:move-2<CR>i')
|
--- @type table<string, { [string]: Mapping, modes: (Mode)[]? }>
|
||||||
set('i', '<M-Down>', '<ESC>:move+<CR>i')
|
local keymap = {
|
||||||
|
move_lines = {
|
||||||
|
['<M-Up>'] = '<ESC>:move-2<CR>i',
|
||||||
|
['<M-Down>'] = '<ESC>:move+<CR>i',
|
||||||
|
modes = { 'i' },
|
||||||
|
},
|
||||||
|
half_screen_scroll = {
|
||||||
|
['<C-Up>'] = '<C-u>zz',
|
||||||
|
['<C-Down>'] = '<C-d>zz',
|
||||||
|
},
|
||||||
|
clipboard_yank = {
|
||||||
|
['<leader>y'] = '"+y',
|
||||||
|
modes = { 'n', 'v' },
|
||||||
|
},
|
||||||
|
terminal_escape = {
|
||||||
|
['<ESC>'] = '<C-\\><C-n>',
|
||||||
|
modes = { 't' },
|
||||||
|
},
|
||||||
|
terminal = {
|
||||||
|
['<leader>t'] = function()
|
||||||
|
OpenTerminal = OpenTerminal or nil
|
||||||
|
|
||||||
set('n', '<C-Up>', '<C-u>zz')
|
local open_buf = vim.api.nvim_get_current_buf()
|
||||||
set('n', '<C-Down>', '<C-d>zz')
|
|
||||||
|
|
||||||
-- yank to clipboard with leader
|
if PreviousBuffer and open_buf == OpenTerminal then
|
||||||
set('n', '<leader>y', '"+y')
|
|
||||||
set('v', '<leader>y', '"+y')
|
|
||||||
|
|
||||||
set('n', 'Q', '<nop>')
|
|
||||||
|
|
||||||
-- terminal
|
|
||||||
-- set('n', '<leader>t', ':split<CR>:term<CR>')
|
|
||||||
OpenTerminal = nil
|
|
||||||
PreviousBuffer = -1
|
|
||||||
set('n', '<leader>t', function()
|
|
||||||
if vim.api.nvim_get_current_buf() == OpenTerminal and PreviousBuffer ~= -1 then
|
|
||||||
vim.api.nvim_set_current_buf(PreviousBuffer)
|
vim.api.nvim_set_current_buf(PreviousBuffer)
|
||||||
PreviousBuffer = -1
|
PreviousBuffer = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
PreviousBuffer = vim.api.nvim_get_current_buf()
|
PreviousBuffer = open_buf
|
||||||
if OpenTerminal ~= nil then
|
|
||||||
|
if OpenTerminal then
|
||||||
vim.api.nvim_set_current_buf(OpenTerminal)
|
vim.api.nvim_set_current_buf(OpenTerminal)
|
||||||
else
|
return
|
||||||
|
end
|
||||||
|
|
||||||
vim.cmd.term()
|
vim.cmd.term()
|
||||||
OpenTerminal = vim.api.nvim_get_current_buf()
|
OpenTerminal = vim.api.nvim_get_current_buf()
|
||||||
vim.api.nvim_create_autocmd({ 'BufDelete' }, {
|
vim.api.nvim_create_autocmd({ 'BufDelete' }, {
|
||||||
callback = function(args)
|
callback = function()
|
||||||
if args.buf == OpenTerminal then
|
|
||||||
OpenTerminal = nil
|
OpenTerminal = nil
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
buffer = OpenTerminal,
|
||||||
})
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
goto_last_buffer = {
|
||||||
|
['<leader>l'] = ':e#<CR>',
|
||||||
|
},
|
||||||
|
scratch_pad = {
|
||||||
|
['<leader>s'] = table.concat({
|
||||||
|
':bo vs',
|
||||||
|
':enew',
|
||||||
|
':setlocal noswapfile',
|
||||||
|
':setlocal bufhidden=hide',
|
||||||
|
':set filetype=markdown',
|
||||||
|
':set syntax=markdown',
|
||||||
|
'',
|
||||||
|
}, '<CR>'),
|
||||||
|
},
|
||||||
|
window_navigation = {
|
||||||
|
['<M-q>'] = '<C-w>q',
|
||||||
|
['<M-left>'] = '<C-w><left>',
|
||||||
|
['<M-right>'] = '<C-w><right>',
|
||||||
|
['<M-up>'] = '<C-w><up>',
|
||||||
|
['<M-down>'] = '<C-w><down>',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tbl in pairs(keymap) do
|
||||||
|
for key, value in pairs(tbl) do
|
||||||
|
if key ~= 'modes' then
|
||||||
|
local modes = tbl.modes --[[ @as Mode[] ]]
|
||||||
|
or { 'n' }
|
||||||
|
for _, mode in ipairs(modes) do
|
||||||
|
--- @cast value Mapping
|
||||||
|
vim.keymap.set(mode, key, value)
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
set('t', '<ESC>', '<C-\\><C-n>')
|
|
||||||
|
|
||||||
-- nice additions
|
|
||||||
set('n', '<leader>er', function()
|
|
||||||
vim.diagnostic.open_float()
|
|
||||||
end)
|
|
||||||
set('n', '<leader>l', ':e#<CR>')
|
|
||||||
-- set('n', '<leader>ca', ':CodeActionMenu<CR>')
|
|
||||||
-- set('n', '<leader>cn', ':IncRename ')
|
|
||||||
|
|
||||||
set('n', '<leader>i', 'cc')
|
|
||||||
-- peek
|
|
||||||
set('n', '<leader>p', vim.lsp.buf.hover)
|
|
||||||
|
|
||||||
-- Scratch pad
|
|
||||||
set(
|
|
||||||
'n',
|
|
||||||
'<leader>s',
|
|
||||||
':bo vs<CR>:enew<CR>:setlocal noswapfile<CR>:setlocal bufhidden=hide<CR>:setlocal buftype=nofile<CR>:set filetype=markdown<CR>:set syntax=markdown<CR>'
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Help
|
|
||||||
-- vim.cmd.cnoreabbrev('h vert h')
|
|
||||||
-- set('n', '<leader>h', ':h <C-r><C-w><CR>')
|
|
||||||
|
|
||||||
-- Comp mode
|
|
||||||
set('n', '<leader>c<CR>', ':Compile<CR>')
|
|
||||||
set('n', '<leader>cs', ':CompileInterrupt<CR>')
|
|
||||||
|
|
||||||
set('n', '<leader>E', ':NextError<CR>')
|
|
||||||
|
|
||||||
-- Windows
|
|
||||||
set('n', '<M-q>', '<C-w>q')
|
|
||||||
set('n', '<M-left>', '<C-w><left>')
|
|
||||||
set('n', '<M-right>', '<C-w><right>')
|
|
||||||
set('n', '<M-up>', '<C-w><up>')
|
|
||||||
set('n', '<M-down>', '<C-w><down>')
|
|
||||||
|
|
||||||
set('n', '<M-S-right>', '<C-w>t<C-w>H')
|
|
||||||
|
|
||||||
Fullscreen = false
|
|
||||||
set('n', '<M-f>', function()
|
|
||||||
if Fullscreen then
|
|
||||||
print('full screen')
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-w>_<C-w>|', true, false, true), 'm', false)
|
|
||||||
else
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-w>=', true, false, true), 'm', false)
|
|
||||||
end
|
end
|
||||||
Fullscreen = not Fullscreen
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
-- Generic
|
|
||||||
set('n', '<leader>q', ':bd!<CR>')
|
|
||||||
|
|||||||
32
.config/nvim/lua/BluePlum/lazy.lua
Normal file
32
.config/nvim/lua/BluePlum/lazy.lua
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
--- @class Lazy
|
||||||
|
--- @field setup fun(opts: table)
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||||
|
|
||||||
|
--- @nodiscard
|
||||||
|
--- @return Lazy?
|
||||||
|
function M.bootstrap()
|
||||||
|
--- @type { fs_stat: fun(path: string): boolean }
|
||||||
|
local fs = vim.uv or vim.loop
|
||||||
|
if fs.fs_stat(lazypath) then
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
return require('lazy')
|
||||||
|
end
|
||||||
|
|
||||||
|
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||||
|
local out = vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
|
||||||
|
|
||||||
|
if vim.v.shell_error ~= 0 then
|
||||||
|
vim.api.nvim_echo({
|
||||||
|
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
|
||||||
|
{ out, 'WarningMsg' },
|
||||||
|
}, true, {})
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return require('lazy')
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
if not vim.g.neovide then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.o.guifont = 'Jetbrains Mono:h17'
|
|
||||||
|
|
||||||
vim.g.neovide_underline_stroke_scale = 2.0
|
|
||||||
vim.g.neovide_theme = 'dark'
|
|
||||||
vim.g.neovide_refresh_rate_idle = 10
|
|
||||||
vim.g.neovide_transparency = 0.6
|
|
||||||
|
|
||||||
-- Scroll
|
|
||||||
vim.g.neovide_scroll_animation_length = 0.1
|
|
||||||
vim.g.neovide_scroll_animation_far_lines = 50
|
|
||||||
|
|
||||||
-- Cursor
|
|
||||||
vim.g.neovide_cursor_animation_length = 0.03
|
|
||||||
vim.g.neovide_cursor_trail_size = 0.5
|
|
||||||
vim.g.neovide_cursor_smooth_blink = true
|
|
||||||
vim.cmd.set('guicursor=i-v-c:blinkwait400-blinkoff350-blinkon250,i-ci-ve:ver25,r-cr:hor20,o:hor20')
|
|
||||||
|
|
||||||
-- Pasting
|
|
||||||
vim.keymap.set('i', '<SC-v>', '<C-r>+')
|
|
||||||
vim.keymap.set('n', '<SC-v>', '"+p')
|
|
||||||
@@ -1,64 +1,96 @@
|
|||||||
-- Tabs for indenting
|
local opts = {
|
||||||
vim.opt.autoindent = true
|
mapleader = ' ',
|
||||||
vim.g.noexpandtab = true
|
|
||||||
vim.opt.tabstop = 4
|
|
||||||
vim.opt.shiftwidth = 4
|
|
||||||
|
|
||||||
-- Line numbers
|
linenr = {
|
||||||
vim.opt.number = true
|
number = true,
|
||||||
vim.opt.relativenumber = true
|
relativenumber = true,
|
||||||
vim.opt.cursorline = true
|
|
||||||
vim.opt.cursorlineopt = 'number'
|
cursorline = true,
|
||||||
|
cursorlineopt = 'number',
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Use tabs for indents
|
||||||
|
indent = {
|
||||||
|
autoindent = true,
|
||||||
|
noexpandtab = true,
|
||||||
|
tabstop = 4,
|
||||||
|
shiftwidth = 4,
|
||||||
|
},
|
||||||
|
|
||||||
|
terminal = {
|
||||||
|
termguicolors = true,
|
||||||
|
shell = '/bin/fish',
|
||||||
|
},
|
||||||
|
|
||||||
|
split = {
|
||||||
|
splitright = true,
|
||||||
|
splitbelow = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
search = {
|
||||||
|
hlsearch = false,
|
||||||
|
incsearch = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
foldlevelstart = 99,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- @param tbl table
|
||||||
|
local function apply(tbl)
|
||||||
|
for key, value in pairs(tbl) do
|
||||||
|
if type(value) == 'table' then
|
||||||
|
apply(value)
|
||||||
|
else
|
||||||
|
if vim.fn.exists('&' .. key) == 1 then
|
||||||
|
vim.opt[key] = value
|
||||||
|
else
|
||||||
|
vim.g[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
apply(opts)
|
||||||
|
|
||||||
|
-- Tabs for indenting
|
||||||
|
-- vim.opt.autoindent = true
|
||||||
|
-- vim.g.noexpandtab = true
|
||||||
|
-- vim.opt.tabstop = 4
|
||||||
|
-- vim.opt.shiftwidth = 4
|
||||||
|
--
|
||||||
|
-- -- Line numbers
|
||||||
|
-- vim.opt.number = true
|
||||||
|
-- vim.opt.relativenumber = true
|
||||||
|
-- vim.opt.cursorline = true
|
||||||
|
-- vim.opt.cursorlineopt = 'number'
|
||||||
|
|
||||||
-- Folding
|
-- Folding
|
||||||
vim.opt.foldlevelstart = 99
|
-- vim.opt.foldlevelstart = 99
|
||||||
|
|
||||||
vim.g.mapleader = ' '
|
-- vim.g.mapleader = ' '
|
||||||
|
|
||||||
-- Terminal
|
-- Terminal
|
||||||
vim.g.termguicolors = true
|
-- vim.g.termguicolors = true
|
||||||
vim.opt.shell = '/bin/fish'
|
-- vim.opt.shell = '/bin/fish'
|
||||||
|
|
||||||
-- LSP
|
-- LSP
|
||||||
vim.lsp.inlay_hint.enable()
|
-- vim.lsp.inlay_hint.enable()
|
||||||
|
|
||||||
-- Splitting
|
-- Splitting
|
||||||
-- vim.cmd.set('splitbelow')
|
-- vim.opt.splitright = true
|
||||||
-- vim.cmd.set('splitright')
|
-- vim.opt.splitbelow = true
|
||||||
vim.opt.splitright = true
|
|
||||||
vim.opt.splitbelow = true
|
|
||||||
|
|
||||||
-- Make text readable
|
-- Make text readable
|
||||||
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
-- vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
||||||
pattern = { '*.md', '*.typ' },
|
-- pattern = { '*.md', '*.typ' },
|
||||||
command = 'setlocal linebreak',
|
-- command = 'setlocal linebreak',
|
||||||
})
|
-- })
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
-- vim.api.nvim_create_autocmd('FileType', {
|
||||||
pattern = 'help',
|
-- pattern = 'help',
|
||||||
command = 'setlocal linebreak',
|
-- command = 'setlocal linebreak',
|
||||||
})
|
-- })
|
||||||
|
|
||||||
vim.cmd.cnoreabbrev('grep', 'Grepper')
|
|
||||||
|
|
||||||
-- Search
|
-- Search
|
||||||
vim.opt.hlsearch = false
|
-- vim.opt.hlsearch = false
|
||||||
vim.opt.incsearch = true
|
-- vim.opt.incsearch = true
|
||||||
|
|
||||||
-- Make dotfile navigation bareble
|
|
||||||
vim.api.nvim_create_user_command('Dot', 'edit ~/.config/nvim', {})
|
|
||||||
|
|
||||||
-- Git
|
|
||||||
vim.api.nvim_create_user_command('Glog', function()
|
|
||||||
local args = {
|
|
||||||
'log',
|
|
||||||
'--graph',
|
|
||||||
'--abbrev-commit',
|
|
||||||
'--decorate',
|
|
||||||
}
|
|
||||||
local str = ''
|
|
||||||
for _, arg in pairs(args) do
|
|
||||||
str = str .. ' ' .. arg
|
|
||||||
end
|
|
||||||
vim.cmd.Git(str)
|
|
||||||
end, {})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user