1
0

General changes + vim changes

This commit is contained in:
2024-10-10 21:17:54 +02:00
parent adc26f9860
commit 6790f75c8a
20 changed files with 273 additions and 138 deletions

View File

@@ -25,3 +25,39 @@ vim.keymap.set('n', '<leader>l', ':e#<CR>')
vim.keymap.set('n', '<leader>i', 'cc')
-- peek
vim.keymap.set('n', '<leader>p', vim.lsp.buf.hover)
-- Scratch pad
vim.keymap.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')
-- Windows
vim.keymap.set('n', '<leader>k', function()
if vim.bo.modified then
if Confirm('Buffer has unsaved changes; write?') then
vim.cmd.write()
vim.cmd.bdelete()
else
vim.cmd('bd!')
end
else
vim.cmd.bdelete()
end
end)
-- Comp mode
vim.keymap.set('n', '<leader>s', function() -- s: start
local command = Input('Enter compilation command > ', vim.g.last_compile_command)
if command then
vim.g.last_compile_command = command
vim.cmd.Compile(command)
end
end)
vim.keymap.set('n', '<leader>E', ':NextError<CR>')
vim.keymap.set('n', '<leader>S', ':Recompile<CR>')

View File

@@ -0,0 +1,24 @@
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')

View File

@@ -7,6 +7,8 @@ vim.opt.shiftwidth = 4
-- Line numbers
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true
vim.opt.cursorlineopt = 'number'
-- Folding
vim.opt.foldlevelstart = 99
@@ -19,3 +21,20 @@ vim.g.terminal_emulator = 'kitty'
-- LSP
vim.lsp.inlay_hint.enable()
-- Splitting
-- vim.cmd.set('splitbelow')
-- vim.cmd.set('splitright')
vim.opt.splitright = true
vim.opt.splitbelow = true
-- Make text readable
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
pattern = { '*.md', '*.typ' },
command = 'setlocal linebreak',
})
vim.api.nvim_create_autocmd('FileType', {
pattern = 'help',
command = 'setlocal linebreak',
})

View File

@@ -0,0 +1,53 @@
function Ask(msg)
vim.cmd.echohl('Question')
vim.cmd.echo('"' .. msg .. '"')
vim.cmd.echohl()
end
function Confirm(msg)
Ask(msg .. ' [Y/n] ')
local answer = vim.fn.getchar()
return answer ~= 110 and answer ~= 27 and answer ~= 37 -- 'n', <ESC>, <SPACE>
end
function Input(prompt, last)
local buffer = ''
while true do
vim.cmd('redraw | echo')
vim.api.nvim_echo({
{ prompt, 'Question' },
last and { last, 'Visual' } or { buffer, 'Normal' },
}, false, {})
local character = vim.fn.getchar()
if pcall(function(char)
if vim.fn.keytrans(char) ~= '<BS>' then
error()
end
end, character) then
last = nil
buffer = vim.fn.slice(buffer, 0, -1)
elseif character == 27 then
vim.cmd('redraw | echo')
return nil
elseif character == 13 then
return last or buffer
elseif
(character == 32 or pcall(function(char)
if vim.fn.keytrans(char) ~= '<Right>' then
error()
end
end, character)) and last
then
buffer = last
if character == 32 then
buffer = buffer .. ' '
end
last = nil
else
last = nil
buffer = buffer .. vim.fn.nr2char(character)
end
end
end