2021-09-07 06:07:40 +02:00
|
|
|
--set some aliases to make typing this faster.
|
2022-11-03 05:00:26 +01:00
|
|
|
local cmd = vim.cmd
|
|
|
|
local opt = vim.opt
|
|
|
|
local fn = vim.fn
|
2023-09-07 18:10:29 +02:00
|
|
|
local map = vim.keymap.set
|
2021-09-12 07:29:48 +02:00
|
|
|
|
2022-04-21 21:51:01 +02:00
|
|
|
--leader key is set through a variable, for some reason.
|
|
|
|
vim.g.mapleader = ';'
|
|
|
|
|
2022-06-20 18:16:43 +02:00
|
|
|
--do package management
|
2021-12-14 07:32:00 +01:00
|
|
|
require('packages')
|
|
|
|
|
2021-09-12 07:29:48 +02:00
|
|
|
--helper functions
|
2022-11-03 05:00:26 +01:00
|
|
|
local function keyCode(string)
|
|
|
|
return vim.api.nvim_replace_termcodes(str, true, true, true, true)
|
|
|
|
end
|
2021-09-12 07:29:48 +02:00
|
|
|
|
2023-10-21 06:59:41 +02:00
|
|
|
local wk = require("which-key")
|
|
|
|
|
2021-09-07 06:07:40 +02:00
|
|
|
--options using vim.opt (aliased, of course.)
|
2022-11-03 05:00:26 +01:00
|
|
|
opt.mouse = 'a'
|
|
|
|
opt.lazyredraw = true
|
|
|
|
opt.termguicolors = true
|
|
|
|
opt.autoread = true
|
|
|
|
opt.swapfile = false
|
|
|
|
opt.history = 500
|
|
|
|
opt.formatoptions = 'rojq'
|
|
|
|
--disable hard text wrapping, will only wrap visually.
|
|
|
|
opt.textwidth = 0
|
|
|
|
opt.wrapmargin = 0
|
|
|
|
opt.wrap = true
|
|
|
|
opt.linebreak = true
|
|
|
|
opt.breakindent = true
|
|
|
|
--add ruler to side of screen.
|
|
|
|
opt.number = true
|
2023-09-07 18:10:29 +02:00
|
|
|
opt.numberwidth=3
|
2022-11-03 05:00:26 +01:00
|
|
|
--displays cordinates of your cursor in statusbar
|
|
|
|
opt.ruler = true
|
|
|
|
--always leave 5 cells between cursor and side of window.
|
|
|
|
opt.scrolloff = 5
|
|
|
|
--better command line completion
|
|
|
|
opt.wildmenu = true
|
|
|
|
--ignore case in search if search is all lowercase.
|
|
|
|
opt.ignorecase = true
|
|
|
|
opt.smartcase = true
|
|
|
|
--show unfinished commands in statusbar.
|
|
|
|
opt.showcmd = true
|
|
|
|
--regex stuff
|
|
|
|
opt.magic = true
|
|
|
|
--always have a status line
|
|
|
|
opt.laststatus = 2
|
|
|
|
--tab stuff
|
|
|
|
opt.tabstop = 4
|
|
|
|
opt.shiftwidth = 0 --zero inherrits tabstop.
|
|
|
|
opt.autoindent = true
|
|
|
|
opt.smartindent = true
|
|
|
|
opt.smarttab = true
|
|
|
|
--space based tabs.
|
|
|
|
-- opt.softtabstop=-1 --negative value inherrits shiftwidth.
|
|
|
|
-- opt.expandtab=true
|
|
|
|
--highlight search results as you type.
|
|
|
|
opt.hlsearch = true
|
|
|
|
opt.incsearch = true
|
|
|
|
--foling stuff
|
|
|
|
opt.foldlevelstart = 5
|
|
|
|
cmd([[source ~/.config/nvim/foldtext.vimrc]])
|
|
|
|
opt.foldmethod = 'indent'
|
|
|
|
opt.foldtext = 'minimal_foldtext()'
|
|
|
|
opt.fillchars = 'stl:=,stlnc: ,vert:|,fold:-'
|
2023-09-07 18:10:29 +02:00
|
|
|
opt.foldcolumn = 'auto:4'
|
2022-11-03 05:00:26 +01:00
|
|
|
opt.foldenable = true
|
|
|
|
opt.foldignore = ''
|
2021-09-12 07:29:48 +02:00
|
|
|
|
|
|
|
--sets colorscheme. to get a list of avalible options, do colorscheme <Space> <C-d>
|
2023-11-03 01:00:26 +01:00
|
|
|
vim.opt.background="dark"
|
|
|
|
-- vim.cmd 'colorscheme moonfly'
|
|
|
|
-- vim.cmd 'colorscheme nightfly'
|
|
|
|
-- vim.cmd 'colorscheme nordic'
|
|
|
|
vim.cmd 'colorscheme gruvbox'
|
2021-09-12 07:29:48 +02:00
|
|
|
|
2022-10-03 17:12:26 +02:00
|
|
|
--function for venn.nvim
|
|
|
|
-- venn.nvim: enable or disable keymappings
|
|
|
|
function _G.Toggle_venn()
|
2022-11-03 05:00:26 +01:00
|
|
|
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
|
|
|
if venn_enabled == "nil" then
|
|
|
|
vim.b.venn_enabled = true
|
|
|
|
vim.cmd [[setlocal ve=all]]
|
|
|
|
-- draw a line on HJKL keystokes
|
|
|
|
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
|
|
|
|
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
|
|
|
|
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
|
|
|
|
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
|
|
|
|
-- draw a box by pressing "f" with visual selection
|
|
|
|
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
|
|
|
|
else
|
|
|
|
vim.cmd [[setlocal ve=]]
|
|
|
|
vim.cmd [[mapclear <buffer>]]
|
|
|
|
vim.b.venn_enabled = nil
|
|
|
|
end
|
2022-10-03 17:12:26 +02:00
|
|
|
end
|
|
|
|
|
2021-09-12 07:29:48 +02:00
|
|
|
--keyboard mappings
|
2023-09-07 18:10:29 +02:00
|
|
|
local function optsWithDesc(desc)
|
|
|
|
return {silent=true, desc=desc}
|
|
|
|
end
|
2022-11-03 05:00:26 +01:00
|
|
|
--toggle spell check
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<leader>sp', ':setlocal spell!<CR>', optsWithDesc("toggle spell check"))
|
2023-03-21 01:42:31 +01:00
|
|
|
--use ctrl+direction to move between splits.
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<C-h>', '<C-w>h', optsWithDesc("move to split to the right"))
|
|
|
|
map('n', '<C-j>', '<C-w>j', optsWithDesc("move to split below"))
|
|
|
|
map('n', '<C-k>', '<C-w>k', optsWithDesc("move to split above"))
|
|
|
|
map('n', '<C-l>', '<C-w>l', optsWithDesc("move to split to the left"))
|
2022-11-03 05:00:26 +01:00
|
|
|
--toggle folds with space.
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<Space>', 'za', optsWithDesc("toggle fold"))
|
2022-11-03 05:00:26 +01:00
|
|
|
--clear highlighting with leader+h
|
2023-09-07 18:10:29 +02:00
|
|
|
map('', '<leader>h', ':nohls<CR>', optsWithDesc("clear highlighting"))
|
|
|
|
--open file browser with leader+t
|
|
|
|
map('n', '<leader>t', ':NvimTreeToggle<CR>', optsWithDesc("toggle file browser"))
|
|
|
|
--open terminal with ctrl-\
|
2022-11-03 05:00:26 +01:00
|
|
|
--open symbols-outline with leader+o
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<leader>o', ':SymbolsOutline<CR>', optsWithDesc("toggle LSP symbol outline"))
|
2022-11-03 05:00:26 +01:00
|
|
|
--telescope stuff
|
2023-10-21 06:59:41 +02:00
|
|
|
-- setup leader-f prefix in whitch-key
|
2023-09-07 18:10:29 +02:00
|
|
|
wk.register {
|
|
|
|
["<leader>f"]={
|
|
|
|
name="+telescope"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map('n', '<leader>ff', ':Telescope find_files<CR>', optsWithDesc("find files"))
|
|
|
|
map('n', '<leader>fg', ':Telescope live_grep<CR>', optsWithDesc("grep"))
|
|
|
|
map('n', '<leader>fb', ':Telescope buffers<CR>', optsWithDesc("find buffers"))
|
|
|
|
map('n', '<leader>fm', ':Telescope marks<CR>', optsWithDesc("find marks"))
|
|
|
|
map('n', '<leader>fp', ':Telescope registers<CR>', optsWithDesc("search registers"))
|
|
|
|
map('n', '<leader>fs', ':Telescope spell_suggest<CR>', optsWithDesc("search spelling suggestions"))
|
|
|
|
map('n', '<leader>fh', ':Telescope keymaps<CR>', optsWithDesc("search keymaps"))
|
|
|
|
map('n', '<leader>fz', ':Telescope current_buffer_fuzzy_find<CR>', optsWithDesc("fuzzy find"))
|
|
|
|
map('n', '<leader>fgc', ':Telescope git_commits<CR>', optsWithDesc("search git commits"))
|
|
|
|
map('n', '<leader>fgb', ':Telescope git_branches<CR>', optsWithDesc("search git branches"))
|
|
|
|
map('n', '<leader>fgs', ':Telescope git_stash<CR>', optsWithDesc("search git stash"))
|
|
|
|
map('n', '<leader>fto', ':TodoTelescope', optsWithDesc("search todos"))
|
|
|
|
map('n', '<leader>ft', ':Telescope treesitter<CR>', optsWithDesc("search treesitter"))
|
2022-11-03 05:00:26 +01:00
|
|
|
--Treesitter context
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<leader>c', ':TSContextToggle<CR>', optsWithDesc("toggle ts context"))
|
2022-11-03 05:00:26 +01:00
|
|
|
--tabline stuff (gt and gT are prev/next tab in stock vim)
|
2023-10-30 23:22:52 +01:00
|
|
|
map('n', 'gf', ':bnext<CR>', optsWithDesc("next buffer"))
|
|
|
|
map('n', 'gF', ':bprevious<CR>', optsWithDesc("prev buffer"))
|
2022-11-03 05:00:26 +01:00
|
|
|
--gitsigns
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<leader>bl', ':Gitsigns toggle_current_line_blame<CR>', optsWithDesc("toggle inline git blame"))
|
2022-11-03 05:00:26 +01:00
|
|
|
-- toggle keymappings for venn using <leader>v
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<leader>v', ":lua Toggle_venn()<CR>", optsWithDesc("toggle venn.nvim"))
|
2023-03-21 01:42:31 +01:00
|
|
|
-- treesj
|
2023-09-07 18:10:29 +02:00
|
|
|
map('n', '<leader>j', ':TSJToggle<CR>', optsWithDesc("treesitter split/join"))
|