|
--[==["move split to new tab - <C-w>T |
|
" :%s/:.*//g " delete everything in line starting with : |
|
" g<C-a> column increase number |
|
" recent neovim versions support commenting via gc example: gcc - comments line |
|
" <C-y> - up <C-e> - down scroll |
|
" H - move to head M- move to middle L - move to low |
|
" <C-pgup> <C-pgdn> move between tabs |
|
" / or ? hotkeys: <C-g> <C-t> goto next/previous |
|
]==] |
|
local vim = vim |
|
local set = vim.opt |
|
set.syntax = 'on' |
|
set.shortmess:append 'I' -- empty start page |
|
set.list = true -- show hidden symbols |
|
set.undofile = true |
|
set.autochdir = true -- auto change working directory |
|
set.cursorline = true -- highlight current line |
|
set.colorcolumn = "120" -- show 120 character limit column |
|
set.termguicolors = true -- correct terminal colors |
|
set.splitbelow = true |
|
set.splitright = true |
|
set.ignorecase = true -- ignore case if no char is Uppercase |
|
set.smartcase = true |
|
set.magic = true -- regex mode |
|
set.shiftwidth = 2 |
|
set.tabstop = 2 |
|
set.softtabstop = 2 |
|
set.expandtab = true |
|
set.keymap = "russian-jcukenwin" -- change keyboard layout in Vim with <Ctrl+^> |
|
set.iminsert = 0 |
|
set.imsearch = 0 |
|
set.hidden = true -- switch buffers without saving |
|
set.laststatus = 2 -- always show statusbar |
|
set.wrap = false -- dont wrap lines |
|
vim.g.netrw_browse_split = 4 -- Open files in previous window. This emulates the typical "drawer" behavior |
|
vim.g.netrw_preview = 1 |
|
vim.g.netrw_alto = 0 |
|
vim.g.netrw_altv = 0 |
|
vim.g.python3_host_prog = 'C:/D/py_path_location/python.exe' |
|
if vim.g.neovide then |
|
-- "C:\Program Files\Neovide\neovide.exe" --neovim-bin "C:\Users\path_to\bin\nvim.exe" --no-vsync |
|
set.wildoptions = { "pum" } |
|
set.pumblend = 15 |
|
set.winblend = 15 |
|
--set.guifont = "Monaspace Neon:h14" |
|
set.guifont = "JetBrains Mono:h14" |
|
vim.g.neovide_cursor_animation_length = 0.016 |
|
vim.g.neovide_refresh_rate = 144 |
|
vim.g.neovide_cursor_animate_in_insert_mode = true |
|
vim.g.neovide_cursor_animate_command_line = true |
|
vim.g.neovide_cursor_antialiasing = true |
|
end |
|
-- Plugins setup, requires 'junegunn/vim-plug', paste init.lua into %LOCALAPPDATA%\nvim |
|
local Plug = vim.fn['plug#'] |
|
vim.call('plug#begin') |
|
Plug 'junegunn/fzf' |
|
Plug 'junegunn/fzf.vim' |
|
Plug ('mhinz/vim-startify', {['on'] = 'Startify'}) |
|
Plug ('mbbill/undotree', {['on'] = 'UndotreeToggle'}) -- requires diff.exe from git |
|
Plug ('psf/Black', {['on'] = 'Black'}) |
|
--Plug ('sbdchd/neoformat', {['on'] = 'Neoformat'}) |
|
Plug ('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'}) |
|
Plug 'beyondmarc/hlsl.vim' |
|
Plug 'HiPhish/rainbow-delimiters.nvim' |
|
Plug ('catppuccin/nvim', { ['as'] = 'catppuccin' }) |
|
Plug ('echasnovski/mini.align', {['branch'] = 'stable'}) |
|
vim.call('plug#end') |
|
-- https://github.com/neovim/neovim/blob/master/runtime/doc/treesitter.txt |
|
require'nvim-treesitter.configs'.setup { |
|
ensure_installed ={"python", "javascript", "vim", "markdown", |
|
"lua", "c", "cpp", "go", "c_sharp", "java", "odin", "rust" }, |
|
highlight = { enable = true, }, |
|
indent = { enable = true, }, |
|
rainbow = { |
|
enable = true, |
|
extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean |
|
max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int |
|
} |
|
} |
|
require'mini.align'.setup() |
|
vim.g.startify_custom_header = {'custom text',} |
|
vim.g.startify_files_number = 25 |
|
--set.background = "light" |
|
vim.cmd[[language messages en]] -- UI |
|
vim.cmd.colorscheme "catppuccin" |
|
|
|
-- vim.api.nvim_set_hl(0, "my_custom_highlight", { |
|
-- bg = "#fbf1c7", |
|
-- fg = "fg", |
|
-- }) |
|
-- vim.api.nvim_create_augroup("_terminal", { clear = true }) |
|
-- vim.api.nvim_create_autocmd("TermOpen", { |
|
-- command = "setlocal winhighlight=Normal:my_custom_highlight", |
|
-- group = "_terminal", |
|
-- }) |
|
|
|
--------------------------------------------------------------------------------------------- |
|
-- hotkeys setup |
|
local opts = { noremap=true, silent=true } |
|
local map = vim.keymap.set |
|
--search in selection |
|
map('x', 'g/', '<Esc>/\\%V') |
|
-- copy paste |
|
map("v", "<C-c>", '"+y', opts) |
|
map("n", "<C-v>", '"+p', opts) |
|
map("v", "<C-v>", '"+p', opts) |
|
map("n", "<C-x>", "dd", opts) |
|
map("v", "<C-x>", '"+d', opts) |
|
-- insert mode hotkey, line above |
|
map('i', '<A-o>', '<Esc>O', opts) |
|
-- exit terminal |
|
map("t", "<Leader><ESC>", "<C-\\><C-n>" ,{noremap = true}) |
|
-- tabs navigation |
|
map("n", "<C-1>", ":tabn 1<CR>", opts) |
|
map("n", "<C-2>", ":tabn 2<CR>", opts) |
|
map("n", "<C-3>", ":tabn 3<CR>", opts) |
|
map("n", "<C-4>", ":tabn 4<CR>", opts) |
|
map("n", "<C-5>", ":tabn 5<CR>", opts) |
|
map("n", "<C-9>", ":tablast <CR>", opts) |
|
-- arrows remap |
|
map('n', '<Up>', '<PageUp>', opts) |
|
map('n', '<Down>', '<PageDown>', opts) |
|
map('n', '<Left>', 'gg', opts) |
|
map('n', '<Right>', 'G', opts) |
|
-- launch last command in split terminal |
|
map('n', '<F2>', ':w<CR><C-w><C-w>Ga<Up><CR><C-\\><C-n><C-w><C-w>') |
|
-- Plugins hotkeys |
|
map('n', '<F3>', ':UndotreeToggle<CR>') |
|
map('n', '<F4>', ':Startify<CR>', { noremap = true }) |
|
map('n', '<F5>', ':Black<CR>', { noremap = true }) |
|
-- default mapleader \ |
|
map('n', '<F11>', function() vim.g.neovide_fullscreen = not vim.g.neovide_fullscreen end, |
|
{ noremap = false, silent = true, desc = 'Toggle Neovide fullscreen' }) |
|
map('n', '<leader>t', function() vim.cmd('tabnew') vim.cmd('Startify') end, |
|
{ noremap = true, silent = true, desc = 'New tab with Startify' }) |
|
map('n', '<leader>h', ':set hlsearch!<CR>', { noremap = true, silent = true, desc = "Toggle search highlight" }) |
|
map('n', '<leader>f', ':Files<CR>', { noremap = true, silent = true, desc = 'FZF Files' }) |
|
map('n', '<leader>rg', ':RG<CR>', { noremap = true, silent = true, desc = 'FZF Ripgrep' }) |
|
map('n', '<leader>b', ':Buffers<CR>', { noremap = true, silent = true, desc = 'FZF Buffers' }) |
|
-- previous and next commits state of the file |
|
map('n', '<leader>1', function() |
|
vim.fn.jobstart({'git', 'checkout', 'HEAD~1'}, { |
|
on_exit = function(_, code, _) |
|
if code == 0 then |
|
vim.notify("Checked out HEAD~1 successfully", vim.log.levels.INFO) |
|
-- Refresh the current file |
|
vim.schedule(function() |
|
vim.cmd('edit') |
|
end) |
|
else |
|
vim.notify("Git checkout failed", vim.log.levels.ERROR) |
|
end |
|
end, |
|
}) |
|
end, opts) |
|
map('n', '<leader>2', function() |
|
vim.fn.jobstart({ |
|
'pwsh.exe', '-NoProfile', '-Command', |
|
'git checkout (git rev-list --topo-order HEAD..master | Select-Object -Last 1)' |
|
}, { |
|
on_exit = function(_, code, _) |
|
if code == 0 then |
|
vim.notify("Checked out to next commit towards master", vim.log.levels.INFO) |
|
vim.schedule(function() |
|
vim.cmd('edit') |
|
end) |
|
else |
|
vim.notify("Git checkout failed", vim.log.levels.ERROR) |
|
end |
|
end, |
|
}) |
|
end, opts) |
|
|