2022-08-18 04:13:50 +02:00
|
|
|
--[[
|
|
|
|
&&&
|
|
|
|
&##& █████╗ ██╗ ███████╗███╗ ███╗██╗
|
|
|
|
&##& ██╔══██╗██║ ██╔════╝████╗ ████║██║
|
|
|
|
BB& ███████║██║ █████╗ ██╔████╔██║██║
|
|
|
|
&GB & ██╔══██║██║ ██╔══╝ ██║╚██╔╝██║██║
|
|
|
|
&GB &BGBBBBBBBB###& ██║ ██║███████╗███████╗██║ ╚═╝ ██║██║
|
|
|
|
GG &GGGGGGGGGGGGGB#& ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝
|
|
|
|
#P# &&#BGGGGGGGGGGG# nvim configuration
|
|
|
|
BP& &GGGGGGGGGB#
|
|
|
|
&#BGPP& &#BGGGGGGGB#
|
|
|
|
&#BGGGGGPP& &&#BGGGGGGB##&
|
|
|
|
&#GPPPGGGGGBPB &&##BGGGGGBB#&&
|
|
|
|
#PPPPPPPGGPG BP& &&##BBGGGGGGBB#&&
|
|
|
|
PPPPPPPPPPPPGBPG&&& &&&&&&###BBBGGGGGGGBB##&&
|
|
|
|
&BGPPPPPPPPPPPPPPGGGGGGGGGGGGGGGGGGGBBB##&&&
|
|
|
|
&&##BBBBGGGGGGGPGBBBBBB####&&&&
|
|
|
|
&#B#&
|
|
|
|
&& ###&
|
|
|
|
&G# &&#&&&
|
|
|
|
&&&
|
|
|
|
]]--
|
|
|
|
|
|
|
|
--|| CORE
|
|
|
|
vim.opt.mouse = 'a' -- mouse can be handy
|
|
|
|
vim.opt.number = true -- show line number
|
|
|
|
vim.opt.cursorline = true -- highlight current line, with theme only visible in number bar
|
|
|
|
vim.opt.tabstop = 4 -- default to tab of size 4
|
|
|
|
vim.opt.shiftwidth = 4 -- default to autoindent by 4
|
|
|
|
vim.opt.expandtab = false -- default to hard tabs
|
|
|
|
vim.opt.wrap = false -- default to no wrap
|
|
|
|
vim.opt.showmode = false -- my statusline handles this
|
|
|
|
vim.opt.showcmd = true
|
|
|
|
vim.opt.wildmode = 'longest,list,full' -- don't accept partial completions until we tab a lot
|
|
|
|
vim.opt.hls = false
|
|
|
|
vim.opt.sessionoptions = "buffers,curdir,localoptions,tabpages,winsize"
|
|
|
|
vim.opt.foldlevelstart = 50
|
|
|
|
vim.opt.termguicolors = true
|
2022-09-01 01:10:22 +02:00
|
|
|
vim.opt.scrolloff = 4
|
2022-09-19 11:56:31 +02:00
|
|
|
vim.opt.sidescrolloff = 8
|
2022-08-18 04:13:50 +02:00
|
|
|
-- vim.opt.signcolumn = "yes"
|
|
|
|
vim.opt.switchbuf = "usetab"
|
2022-08-18 16:12:15 +02:00
|
|
|
vim.g.mapleader = "\\"
|
2022-08-18 04:13:50 +02:00
|
|
|
|
|
|
|
vim.opt.list = true -- always show whitespace chars
|
|
|
|
vim.opt.listchars = "tab:│ ,space:·,trail:•,nbsp:▭,precedes:◀,extends:▶"
|
|
|
|
|
|
|
|
vim.opt.winheight = 3
|
|
|
|
vim.opt.winminheight = 3
|
|
|
|
vim.opt.winwidth = 12
|
|
|
|
vim.opt.winminwidth = 12
|
|
|
|
|
2022-09-01 01:10:22 +02:00
|
|
|
|
2022-08-18 04:13:50 +02:00
|
|
|
-- Tabline
|
|
|
|
-- TODO customize structure to make selected tab use same hi as mode, maybe
|
|
|
|
-- check https://gist.github.com/kanterov/1517990 ?
|
|
|
|
vim.opt.showtabline = 1 -- set to 2 to always show tabline
|
|
|
|
|
|
|
|
-- Statusline
|
|
|
|
STATUSLINE = require('statusline')
|
|
|
|
vim.opt.laststatus = 3 -- show one global statusline
|
2022-08-18 04:42:18 +02:00
|
|
|
vim.opt.statusline = "%!v:lua.STATUSLINE.display()"
|
2022-08-18 04:13:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
-- Netrw settings
|
2022-10-28 11:14:01 +02:00
|
|
|
vim.g.netrw_liststyle = 3
|
|
|
|
-- vim.g.netrw_banner = 0
|
2022-08-18 04:13:50 +02:00
|
|
|
vim.g.netrw_browse_split = 2
|
|
|
|
vim.g.netrw_winsize = 12
|
|
|
|
|
2022-09-01 01:35:55 +02:00
|
|
|
-- Neovide settings
|
2022-09-19 11:56:31 +02:00
|
|
|
vim.g.neovide_transparency = 0.9
|
2022-09-01 01:35:55 +02:00
|
|
|
vim.g.neovide_cursor_vfx_mode = "wireframe"
|
2022-10-28 11:14:01 +02:00
|
|
|
vim.g.neovide_refresh_rate = 120
|
2022-09-01 01:35:55 +02:00
|
|
|
vim.opt.guifont = { "Fira Code", ":h10" }
|
|
|
|
|
2022-08-18 04:13:50 +02:00
|
|
|
-- Wiki.vim settings
|
|
|
|
vim.g.wiki_root = "~/Documents/wiki"
|
|
|
|
|
|
|
|
-- vim.opt.timeoutlen = 500 -- set shorter timeout for keys
|
|
|
|
-- vim.opt.ttimeoutlen = 10 -- set even shorter timeout for ESC
|
|
|
|
|
2022-08-18 05:16:43 +02:00
|
|
|
|
|
|
|
--|| NUMBERS
|
2022-08-18 04:13:50 +02:00
|
|
|
-- relativenumbers are very handy for navigation, but absolute are useful in general
|
|
|
|
-- and better looking. Keep numbers relative only on active buffer and if in Normal mode.
|
|
|
|
vim.opt.relativenumber = true
|
|
|
|
local number_mode_group = vim.api.nvim_create_augroup("NumberModeGroup", {clear=true})
|
|
|
|
vim.api.nvim_create_autocmd(
|
|
|
|
{ "InsertLeave", "BufEnter", "FocusGained", "WinEnter" },
|
2022-08-18 16:12:15 +02:00
|
|
|
{
|
|
|
|
callback = function() if vim.wo.number then vim.wo.relativenumber = true end end,
|
|
|
|
group = number_mode_group
|
|
|
|
}
|
2022-08-18 04:13:50 +02:00
|
|
|
)
|
|
|
|
vim.api.nvim_create_autocmd(
|
|
|
|
{ "InsertEnter", "BufLeave", "FocusLost", "WinLeave" },
|
2022-08-18 16:12:15 +02:00
|
|
|
{
|
|
|
|
callback=function() if vim.wo.number then vim.opt.relativenumber = false end end,
|
|
|
|
group=number_mode_group
|
|
|
|
}
|
2022-08-18 04:13:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
--|| STATE MANAGEMENT
|
|
|
|
VIMDIR = vim.fn.stdpath('data') .. '/site/'
|
|
|
|
|
|
|
|
-- add command :SaveSession which wraps around ':mksession! .session.vim'
|
|
|
|
-- when vim in started without args, try to load .session.vim in cwd
|
|
|
|
require("state")
|
|
|
|
|
|
|
|
-- keep track of undos across sessions
|
|
|
|
local undo_path = VIMDIR .. "undo/"
|
|
|
|
if not vim.fn.isdirectory(undo_path) then
|
|
|
|
vim.fn.mkdir(undo_path, "p")
|
|
|
|
end
|
|
|
|
vim.opt.undofile = true
|
|
|
|
vim.opt.undodir = undo_path
|
|
|
|
|
|
|
|
|
|
|
|
--|| KEYBINDS
|
|
|
|
KEYBINDS = require('keybinds')
|
|
|
|
KEYBINDS:set_global_keys({})
|
|
|
|
KEYBINDS:set_navigation_keys({})
|
|
|
|
-- Telescope and nvim-lsp will set more keybinds if loaded
|
|
|
|
|
|
|
|
|
|
|
|
--|| PLUGINS
|
|
|
|
local install_path = VIMDIR..'/pack/packer/start/packer.nvim'
|
|
|
|
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
|
|
|
local packer_bootstrap = vim.fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
|
|
|
end
|
|
|
|
|
2022-08-18 04:42:18 +02:00
|
|
|
PLUGINS = require('plugins')
|
2022-08-18 04:13:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
--|| THEME
|
2022-10-02 00:57:30 +02:00
|
|
|
vim.cmd("colorscheme peak") -- TODO can I do it in lua?
|
2022-08-18 04:42:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
--|| UTILITY
|
|
|
|
function P(something) print(vim.inspect(something)) end
|
2022-08-18 05:06:02 +02:00
|
|
|
|
2022-08-18 16:12:15 +02:00
|
|
|
function HL()
|
|
|
|
local id = vim.fn.synID(vim.fn.line('.'), vim.fn.col('.'), 1)
|
|
|
|
local id_trans = vim.fn.synIDtrans(id)
|
|
|
|
local name = vim.fn.synIDattr(id_trans, 'name')
|
2022-08-19 05:23:12 +02:00
|
|
|
print(string.format("Highlight #%d -> %s", id, id_trans))
|
2022-08-18 16:12:15 +02:00
|
|
|
P(name)
|
|
|
|
end
|
|
|
|
|
2022-08-19 05:23:12 +02:00
|
|
|
local function shell_cmd(str)
|
|
|
|
local stdout = vim.fn.system(str)
|
|
|
|
local output, _ = stdout:sub(0, #stdout-1):gsub("\t", " ")
|
|
|
|
print(output)
|
|
|
|
return vim.v.shell_error == 0
|
|
|
|
end
|
|
|
|
|
2022-08-18 05:06:02 +02:00
|
|
|
vim.api.nvim_create_user_command(
|
|
|
|
'UpdateConfig',
|
|
|
|
function(args)
|
2022-08-19 05:23:12 +02:00
|
|
|
local cfg_path = vim.fn.stdpath('config')
|
|
|
|
if args.bang then
|
|
|
|
if not shell_cmd(string.format("git -C %s reset --hard", cfg_path)) then return end
|
|
|
|
end
|
|
|
|
if #args.args > 0 then
|
|
|
|
if not shell_cmd(string.format("git -C %s checkout %s", cfg_path, args.args)) then return end
|
|
|
|
end
|
|
|
|
shell_cmd(string.format("git -C %s pull", cfg_path))
|
2022-08-18 05:06:02 +02:00
|
|
|
end,
|
2022-08-19 05:23:12 +02:00
|
|
|
{bang=true, nargs='?'}
|
2022-08-18 05:06:02 +02:00
|
|
|
)
|
2022-10-28 11:25:15 +02:00
|
|
|
|
|
|
|
-- since builtin :retab! will expand also alignment spaces,
|
|
|
|
-- I made this simple command to use 'unexpand'/'expand'
|
|
|
|
vim.api.nvim_create_user_command(
|
|
|
|
'Retab',
|
|
|
|
function(args)
|
|
|
|
local tablen = 4
|
|
|
|
local cmd = "unexpand"
|
|
|
|
local opt = "--first-only"
|
|
|
|
if #args.args > 0 then
|
|
|
|
tablen = args.args
|
|
|
|
end
|
|
|
|
if args.bang then
|
|
|
|
cmd = "expand"
|
|
|
|
opt = "--initial"
|
|
|
|
end
|
|
|
|
vim.cmd(string.format("%%!%s -t %d %s", cmd, tablen, opt))
|
|
|
|
end,
|
|
|
|
{bang=true, nargs='?'}
|
|
|
|
)
|