mirror of
https://github.com/nmasur/dotfiles
synced 2024-12-25 05:24:52 +00:00
test splitting up init.lua
This commit is contained in:
parent
ce52be726f
commit
d6657cee86
3
Makefile
3
Makefile
@ -36,9 +36,6 @@ programs:
|
||||
./scripts/setup_cheatsheet
|
||||
./scripts/setup_ytfzf
|
||||
|
||||
python: brews
|
||||
npm install -g pyright
|
||||
|
||||
nix:
|
||||
git add -A
|
||||
doas nixos-rebuild switch --flake .
|
||||
|
@ -8,9 +8,14 @@
|
||||
];
|
||||
|
||||
xdg.configFile = {
|
||||
"nvim/init.lua".text = lib.mkOrder 100 ''
|
||||
${builtins.readFile ./init.lua}
|
||||
'';
|
||||
"nvim/init.lua".text = lib.mkMerge [
|
||||
(lib.mkOrder 100 ''
|
||||
${builtins.readFile ./packer.lua}
|
||||
${builtins.readFile ./settings.lua}
|
||||
${builtins.readFile ./functions.lua}
|
||||
${builtins.readFile ./keybinds.lua}
|
||||
'')
|
||||
];
|
||||
};
|
||||
|
||||
programs.git.extraConfig.core.editor = "nvim";
|
||||
|
49
modules/editor/neovim/functions.lua
Normal file
49
modules/editor/neovim/functions.lua
Normal file
@ -0,0 +1,49 @@
|
||||
-- ===========================================================================
|
||||
-- Custom Functions
|
||||
-- ===========================================================================
|
||||
|
||||
grep_notes = function()
|
||||
local opts = {
|
||||
prompt_title = "Search Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
require("telescope.builtin").live_grep(opts)
|
||||
end
|
||||
|
||||
find_notes = function()
|
||||
local opts = {
|
||||
prompt_title = "Find Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
require("telescope.builtin").find_files(opts)
|
||||
end
|
||||
|
||||
find_downloads = function()
|
||||
local opts = {
|
||||
prompt_title = "Find Downloads",
|
||||
cwd = "~/Downloads",
|
||||
}
|
||||
require("telescope").extensions.file_browser.file_browser(opts)
|
||||
end
|
||||
|
||||
choose_project = function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").extensions.project.project(opts)
|
||||
end
|
||||
|
||||
command_history = function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 15,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope.builtin").command_history(opts)
|
||||
end
|
115
modules/editor/neovim/keybinds.lua
Normal file
115
modules/editor/neovim/keybinds.lua
Normal file
@ -0,0 +1,115 @@
|
||||
-- ===========================================================================
|
||||
-- Key Mapping
|
||||
-- ===========================================================================
|
||||
|
||||
-- Function to cut down config boilerplate
|
||||
local key = function(mode, key_sequence, action, params)
|
||||
params = params or {}
|
||||
params["noremap"] = true
|
||||
vim.api.nvim_set_keymap(mode, key_sequence, action, params)
|
||||
end
|
||||
|
||||
-- Remap space as leader key
|
||||
key("", "<Space>", "<Nop>", { silent = true })
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Keep selection when changing indentation
|
||||
key("v", "<", "<gv")
|
||||
key("v", ">", ">gv")
|
||||
|
||||
-- Clear search register
|
||||
key("n", "<CR>", ":noh<CR><CR>", { silent = true })
|
||||
|
||||
-- Shuffle lines around
|
||||
key("n", "<A-j>", ":m .+1<CR>==")
|
||||
key("n", "<A-k>", ":m .-2<CR>==")
|
||||
key("i", "<A-j>", "<Esc>:m .+1<CR>==gi")
|
||||
key("i", "<A-k>", "<Esc>:m .-2<CR>==gi")
|
||||
key("v", "<A-j>", ":m '>+1<CR>gv=gv")
|
||||
key("v", "<A-k>", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- Telescope (fuzzy finder)
|
||||
key("n", "<Leader>k", ":Telescope keymaps<CR>")
|
||||
key("n", "<Leader>/", ":Telescope live_grep<CR>")
|
||||
key("n", "<Leader>ff", ":Telescope find_files<CR>")
|
||||
key("n", "<Leader>fp", ":Telescope git_files<CR>")
|
||||
key("n", "<Leader>fN", "<Cmd>lua find_notes()<CR>")
|
||||
key("n", "<Leader>N", "<Cmd>lua grep_notes()<CR>")
|
||||
key("n", "<Leader>fD", "<Cmd>lua find_downloads()<CR>")
|
||||
key("n", "<Leader>fa", ":Telescope file_browser<CR>")
|
||||
key("n", "<Leader>fw", ":Telescope grep_string<CR>")
|
||||
key("n", "<Leader>wt", ":Telescope tmux sessions<CR>")
|
||||
key("n", "<Leader>ww", ":Telescope tmux windows<CR>")
|
||||
key("n", "<Leader>w/", ":Telescope tmux pane_contents<CR>")
|
||||
key("n", "<Leader>fz", ":Telescope zoxide list<CR>")
|
||||
key("n", "<Leader>b", ":Telescope buffers<CR>")
|
||||
key("n", "<Leader>hh", ":Telescope help_tags<CR>")
|
||||
key("n", "<Leader>fr", ":Telescope oldfiles<CR>")
|
||||
key("n", "<Leader>cc", ":Telescope commands<CR>")
|
||||
key("n", "<Leader>cr", "<Cmd>lua command_history()<CR>")
|
||||
key("n", "<Leader>y", "<Cmd>lua clipboard_history()<CR>")
|
||||
key("i", "<c-y>", "<Cmd>lua clipboard_history()<CR>")
|
||||
key("n", "<Leader>s", ":Telescope current_buffer_fuzzy_find<CR>")
|
||||
key("n", "<Leader>gc", ":Telescope git_commits<CR>")
|
||||
key("n", "<Leader>gf", ":Telescope git_bcommits<CR>")
|
||||
key("n", "<Leader>gb", ":Telescope git_branches<CR>")
|
||||
key("n", "<Leader>gs", ":Telescope git_status<CR>")
|
||||
key("n", "<C-p>", "<Cmd>lua choose_project()<CR>")
|
||||
|
||||
-- LSP
|
||||
key("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", { silent = true })
|
||||
key("n", "gT", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", { silent = true })
|
||||
key("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>", { silent = true })
|
||||
key("n", "gh", "<Cmd>lua vim.lsp.buf.hover()<CR>", { silent = true })
|
||||
key("n", "gr", "<Cmd>Telescope lsp_references<CR>", { silent = true })
|
||||
key("n", "<Leader>R", "<Cmd>lua vim.lsp.buf.rename()<CR>", { silent = true })
|
||||
key("n", "]e", "<Cmd>lua vim.diagnostic.goto_next()<CR>", { silent = true })
|
||||
key("n", "[e", "<Cmd>lua vim.diagnostic.goto_prev()<CR>", { silent = true })
|
||||
key("n", "<Leader>e", "<Cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", { silent = true })
|
||||
key("n", "<Leader>E", "<Cmd>lua vim.lsp.buf.code_action()<CR>", { silent = true })
|
||||
|
||||
-- File commands
|
||||
key("n", "<Leader>q", ":quit<CR>")
|
||||
key("n", "<Leader>Q", ":quitall<CR>")
|
||||
key("n", "<Leader>fs", ":write<CR>")
|
||||
key("n", "<Leader>fd", ":lcd %:p:h<CR>", { silent = true })
|
||||
key("n", "<Leader>fu", ":lcd ..<CR>", { silent = true })
|
||||
key("n", "<Leader><Tab>", ":b#<CR>", { silent = true })
|
||||
key("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", { silent = true })
|
||||
key("n", "<Leader>tt", [[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]])
|
||||
key("n", "<Leader>jj", ":!journal<CR>:e<CR>")
|
||||
|
||||
-- Window commands
|
||||
key("n", "<Leader>wv", ":vsplit<CR>")
|
||||
key("n", "<Leader>wh", ":split<CR>")
|
||||
key("n", "<Leader>wm", ":only<CR>")
|
||||
|
||||
-- Tabularize
|
||||
key("", "<Leader>ta", ":Tabularize /")
|
||||
key("", "<Leader>t#", ":Tabularize /#<CR>")
|
||||
key("", "<Leader>tl", ":Tabularize /---<CR>")
|
||||
|
||||
-- Vimrc editing
|
||||
key("n", "<Leader>fv", ":edit $DOTS/nvim.configlink/init.lua<CR>")
|
||||
key("n", "<Leader>rr", ":luafile $MYVIMRC<CR>")
|
||||
key("n", "<Leader>rp", ":luafile $MYVIMRC<CR>:PackerInstall<CR>:")
|
||||
key("n", "<Leader>rc", ":luafile $MYVIMRC<CR>:PackerCompile<CR>")
|
||||
|
||||
-- Keep cursor in place
|
||||
key("n", "n", "nzz")
|
||||
key("n", "N", "Nzz")
|
||||
key("n", "J", "mzJ`z") --- Mark and jump back to it
|
||||
|
||||
-- Add undo breakpoints
|
||||
key("i", ",", ",<C-g>u")
|
||||
key("i", ".", ".<C-g>u")
|
||||
key("i", "!", "!<C-g>u")
|
||||
key("i", "?", "?<C-g>u")
|
||||
|
||||
-- Other
|
||||
key("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
key("n", "<A-CR>", ":noh<CR>", { silent = true }) --- Clear search in VimWiki
|
||||
key("n", "Y", "y$") --- Copy to end of line
|
||||
key("v", "<C-r>", "y<Esc>:%s/<C-r>+//gc<left><left><left>") --- Substitute selected
|
||||
key("v", "D", "y'>gp") --- Duplicate selected
|
@ -397,286 +397,3 @@ require("packer").startup(function(use)
|
||||
require("packer").sync()
|
||||
end
|
||||
end)
|
||||
|
||||
-- ===========================================================================
|
||||
-- Settings
|
||||
-- ===========================================================================
|
||||
|
||||
vim.o.termguicolors = true --- Set to truecolor
|
||||
vim.o.hidden = true --- Don't unload buffers when leaving them
|
||||
vim.wo.number = true --- Show line numbers
|
||||
vim.wo.relativenumber = true --- Relative numbers instead of absolute
|
||||
vim.o.list = true --- Reveal whitespace with dashes
|
||||
vim.o.expandtab = true --- Tabs into spaces
|
||||
vim.o.shiftwidth = 4 --- Amount to shift with > key
|
||||
vim.o.softtabstop = 4 --- Amount to shift with <TAB> key
|
||||
vim.o.ignorecase = true --- Ignore case when searching
|
||||
vim.o.smartcase = true --- Check case when using capitals in search
|
||||
vim.o.infercase = true --- Don't match cases when completing suggestions
|
||||
vim.o.incsearch = true --- Search while typing
|
||||
vim.o.visualbell = true --- No sounds
|
||||
vim.o.scrolljump = 1 --- Number of lines to scroll
|
||||
vim.o.scrolloff = 3 --- Margin of lines to see while scrolling
|
||||
vim.o.splitright = true --- Vertical splits on the right side
|
||||
vim.o.splitbelow = true --- Horizontal splits on the bottom side
|
||||
vim.o.pastetoggle = "<F3>" --- Use F3 to enter raw paste mode
|
||||
vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking
|
||||
vim.o.updatetime = 300 --- Faster diagnostics
|
||||
vim.o.mouse = "nv" --- Mouse interaction / scrolling
|
||||
|
||||
-- Neovim features
|
||||
vim.o.inccommand = "split" --- Live preview search and replace
|
||||
--- Required for nvim-cmp completion
|
||||
vim.opt.completeopt = {
|
||||
"menu",
|
||||
"menuone",
|
||||
"noselect",
|
||||
}
|
||||
-- Required until 0.6.0: do not source the default filetype.vim
|
||||
vim.g.did_load_filetypes = 1
|
||||
|
||||
-- Remember last position when reopening file
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Better backup, swap and undo storage
|
||||
vim.o.backup = true --- Easier to recover and more secure
|
||||
vim.bo.swapfile = false --- Instead of swaps, create backups
|
||||
vim.bo.undofile = true --- Keeps undos after quit
|
||||
|
||||
-- Create backup directories if they don't exist
|
||||
-- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433
|
||||
vim.o.backupdir = vim.fn.stdpath("cache") .. "/backup"
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
if !isdirectory(&backupdir)
|
||||
call mkdir(&backupdir, "p")
|
||||
endif
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- LaTeX options
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Highlight when yanking
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Netrw
|
||||
vim.g.netrw_liststyle = 3 -- Change style to 'tree' view
|
||||
vim.g.netrw_banner = 0 -- Remove useless banner
|
||||
vim.g.netrw_winsize = 15 -- Explore window takes % of page
|
||||
vim.g.netrw_browse_split = 4 -- Open in previous window
|
||||
vim.g.netrw_altv = 1 -- Always split left
|
||||
|
||||
-- VimWiki
|
||||
vim.g.vimwiki_list = {
|
||||
{
|
||||
["path"] = "$NOTES_PATH",
|
||||
["syntax"] = "markdown",
|
||||
["index"] = "home",
|
||||
["ext"] = ".md",
|
||||
},
|
||||
}
|
||||
vim.g.vimwiki_key_mappings = {
|
||||
["all_maps"] = 1,
|
||||
["mouse"] = 1,
|
||||
}
|
||||
vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open
|
||||
vim.g.vimwiki_create_link = 0 -- Don't automatically create new links
|
||||
vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression
|
||||
vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au FileType markdown inoremap ;tt <Esc>:AddTag<CR>
|
||||
|
||||
function! PInsert(item)
|
||||
let @z=a:item
|
||||
norm "zpx
|
||||
endfunction
|
||||
|
||||
command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')})
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- ===========================================================================
|
||||
-- Custom Functions
|
||||
-- ===========================================================================
|
||||
|
||||
grep_notes = function()
|
||||
local opts = {
|
||||
prompt_title = "Search Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
require("telescope.builtin").live_grep(opts)
|
||||
end
|
||||
|
||||
find_notes = function()
|
||||
local opts = {
|
||||
prompt_title = "Find Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
require("telescope.builtin").find_files(opts)
|
||||
end
|
||||
|
||||
find_downloads = function()
|
||||
local opts = {
|
||||
prompt_title = "Find Downloads",
|
||||
cwd = "~/Downloads",
|
||||
}
|
||||
require("telescope").extensions.file_browser.file_browser(opts)
|
||||
end
|
||||
|
||||
choose_project = function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").extensions.project.project(opts)
|
||||
end
|
||||
|
||||
command_history = function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 15,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope.builtin").command_history(opts)
|
||||
end
|
||||
|
||||
-- ===========================================================================
|
||||
-- Key Mapping
|
||||
-- ===========================================================================
|
||||
|
||||
-- Function to cut down config boilerplate
|
||||
local key = function(mode, key_sequence, action, params)
|
||||
params = params or {}
|
||||
params["noremap"] = true
|
||||
vim.api.nvim_set_keymap(mode, key_sequence, action, params)
|
||||
end
|
||||
|
||||
-- Remap space as leader key
|
||||
key("", "<Space>", "<Nop>", { silent = true })
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Keep selection when changing indentation
|
||||
key("v", "<", "<gv")
|
||||
key("v", ">", ">gv")
|
||||
|
||||
-- Clear search register
|
||||
key("n", "<CR>", ":noh<CR><CR>", { silent = true })
|
||||
|
||||
-- Shuffle lines around
|
||||
key("n", "<A-j>", ":m .+1<CR>==")
|
||||
key("n", "<A-k>", ":m .-2<CR>==")
|
||||
key("i", "<A-j>", "<Esc>:m .+1<CR>==gi")
|
||||
key("i", "<A-k>", "<Esc>:m .-2<CR>==gi")
|
||||
key("v", "<A-j>", ":m '>+1<CR>gv=gv")
|
||||
key("v", "<A-k>", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- Telescope (fuzzy finder)
|
||||
key("n", "<Leader>k", ":Telescope keymaps<CR>")
|
||||
key("n", "<Leader>/", ":Telescope live_grep<CR>")
|
||||
key("n", "<Leader>ff", ":Telescope find_files<CR>")
|
||||
key("n", "<Leader>fp", ":Telescope git_files<CR>")
|
||||
key("n", "<Leader>fN", "<Cmd>lua find_notes()<CR>")
|
||||
key("n", "<Leader>N", "<Cmd>lua grep_notes()<CR>")
|
||||
key("n", "<Leader>fD", "<Cmd>lua find_downloads()<CR>")
|
||||
key("n", "<Leader>fa", ":Telescope file_browser<CR>")
|
||||
key("n", "<Leader>fw", ":Telescope grep_string<CR>")
|
||||
key("n", "<Leader>wt", ":Telescope tmux sessions<CR>")
|
||||
key("n", "<Leader>ww", ":Telescope tmux windows<CR>")
|
||||
key("n", "<Leader>w/", ":Telescope tmux pane_contents<CR>")
|
||||
key("n", "<Leader>fz", ":Telescope zoxide list<CR>")
|
||||
key("n", "<Leader>b", ":Telescope buffers<CR>")
|
||||
key("n", "<Leader>hh", ":Telescope help_tags<CR>")
|
||||
key("n", "<Leader>fr", ":Telescope oldfiles<CR>")
|
||||
key("n", "<Leader>cc", ":Telescope commands<CR>")
|
||||
key("n", "<Leader>cr", "<Cmd>lua command_history()<CR>")
|
||||
key("n", "<Leader>y", "<Cmd>lua clipboard_history()<CR>")
|
||||
key("i", "<c-y>", "<Cmd>lua clipboard_history()<CR>")
|
||||
key("n", "<Leader>s", ":Telescope current_buffer_fuzzy_find<CR>")
|
||||
key("n", "<Leader>gc", ":Telescope git_commits<CR>")
|
||||
key("n", "<Leader>gf", ":Telescope git_bcommits<CR>")
|
||||
key("n", "<Leader>gb", ":Telescope git_branches<CR>")
|
||||
key("n", "<Leader>gs", ":Telescope git_status<CR>")
|
||||
key("n", "<C-p>", "<Cmd>lua choose_project()<CR>")
|
||||
|
||||
-- LSP
|
||||
key("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", { silent = true })
|
||||
key("n", "gT", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", { silent = true })
|
||||
key("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>", { silent = true })
|
||||
key("n", "gh", "<Cmd>lua vim.lsp.buf.hover()<CR>", { silent = true })
|
||||
key("n", "gr", "<Cmd>Telescope lsp_references<CR>", { silent = true })
|
||||
key("n", "<Leader>R", "<Cmd>lua vim.lsp.buf.rename()<CR>", { silent = true })
|
||||
key("n", "]e", "<Cmd>lua vim.diagnostic.goto_next()<CR>", { silent = true })
|
||||
key("n", "[e", "<Cmd>lua vim.diagnostic.goto_prev()<CR>", { silent = true })
|
||||
key("n", "<Leader>e", "<Cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", { silent = true })
|
||||
key("n", "<Leader>E", "<Cmd>lua vim.lsp.buf.code_action()<CR>", { silent = true })
|
||||
|
||||
-- File commands
|
||||
key("n", "<Leader>q", ":quit<CR>")
|
||||
key("n", "<Leader>Q", ":quitall<CR>")
|
||||
key("n", "<Leader>fs", ":write<CR>")
|
||||
key("n", "<Leader>fd", ":lcd %:p:h<CR>", { silent = true })
|
||||
key("n", "<Leader>fu", ":lcd ..<CR>", { silent = true })
|
||||
key("n", "<Leader><Tab>", ":b#<CR>", { silent = true })
|
||||
key("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", { silent = true })
|
||||
key("n", "<Leader>tt", [[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]])
|
||||
key("n", "<Leader>jj", ":!journal<CR>:e<CR>")
|
||||
|
||||
-- Window commands
|
||||
key("n", "<Leader>wv", ":vsplit<CR>")
|
||||
key("n", "<Leader>wh", ":split<CR>")
|
||||
key("n", "<Leader>wm", ":only<CR>")
|
||||
|
||||
-- Tabularize
|
||||
key("", "<Leader>ta", ":Tabularize /")
|
||||
key("", "<Leader>t#", ":Tabularize /#<CR>")
|
||||
key("", "<Leader>tl", ":Tabularize /---<CR>")
|
||||
|
||||
-- Vimrc editing
|
||||
key("n", "<Leader>fv", ":edit $DOTS/nvim.configlink/init.lua<CR>")
|
||||
key("n", "<Leader>rr", ":luafile $MYVIMRC<CR>")
|
||||
key("n", "<Leader>rp", ":luafile $MYVIMRC<CR>:PackerInstall<CR>:")
|
||||
key("n", "<Leader>rc", ":luafile $MYVIMRC<CR>:PackerCompile<CR>")
|
||||
|
||||
-- Keep cursor in place
|
||||
key("n", "n", "nzz")
|
||||
key("n", "N", "Nzz")
|
||||
key("n", "J", "mzJ`z") --- Mark and jump back to it
|
||||
|
||||
-- Add undo breakpoints
|
||||
key("i", ",", ",<C-g>u")
|
||||
key("i", ".", ".<C-g>u")
|
||||
key("i", "!", "!<C-g>u")
|
||||
key("i", "?", "?<C-g>u")
|
||||
|
||||
-- Other
|
||||
key("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
key("n", "<A-CR>", ":noh<CR>", { silent = true }) --- Clear search in VimWiki
|
||||
key("n", "Y", "y$") --- Copy to end of line
|
||||
key("v", "<C-r>", "y<Esc>:%s/<C-r>+//gc<left><left><left>") --- Substitute selected
|
||||
key("v", "D", "y'>gp") --- Duplicate selected
|
116
modules/editor/neovim/settings.lua
Normal file
116
modules/editor/neovim/settings.lua
Normal file
@ -0,0 +1,116 @@
|
||||
-- ===========================================================================
|
||||
-- Settings
|
||||
-- ===========================================================================
|
||||
|
||||
vim.o.termguicolors = true --- Set to truecolor
|
||||
vim.o.hidden = true --- Don't unload buffers when leaving them
|
||||
vim.wo.number = true --- Show line numbers
|
||||
vim.wo.relativenumber = true --- Relative numbers instead of absolute
|
||||
vim.o.list = true --- Reveal whitespace with dashes
|
||||
vim.o.expandtab = true --- Tabs into spaces
|
||||
vim.o.shiftwidth = 4 --- Amount to shift with > key
|
||||
vim.o.softtabstop = 4 --- Amount to shift with <TAB> key
|
||||
vim.o.ignorecase = true --- Ignore case when searching
|
||||
vim.o.smartcase = true --- Check case when using capitals in search
|
||||
vim.o.infercase = true --- Don't match cases when completing suggestions
|
||||
vim.o.incsearch = true --- Search while typing
|
||||
vim.o.visualbell = true --- No sounds
|
||||
vim.o.scrolljump = 1 --- Number of lines to scroll
|
||||
vim.o.scrolloff = 3 --- Margin of lines to see while scrolling
|
||||
vim.o.splitright = true --- Vertical splits on the right side
|
||||
vim.o.splitbelow = true --- Horizontal splits on the bottom side
|
||||
vim.o.pastetoggle = "<F3>" --- Use F3 to enter raw paste mode
|
||||
vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking
|
||||
vim.o.updatetime = 300 --- Faster diagnostics
|
||||
vim.o.mouse = "nv" --- Mouse interaction / scrolling
|
||||
|
||||
-- Neovim features
|
||||
vim.o.inccommand = "split" --- Live preview search and replace
|
||||
--- Required for nvim-cmp completion
|
||||
vim.opt.completeopt = {
|
||||
"menu",
|
||||
"menuone",
|
||||
"noselect",
|
||||
}
|
||||
-- Required until 0.6.0: do not source the default filetype.vim
|
||||
vim.g.did_load_filetypes = 1
|
||||
|
||||
-- Remember last position when reopening file
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Better backup, swap and undo storage
|
||||
vim.o.backup = true --- Easier to recover and more secure
|
||||
vim.bo.swapfile = false --- Instead of swaps, create backups
|
||||
vim.bo.undofile = true --- Keeps undos after quit
|
||||
|
||||
-- Create backup directories if they don't exist
|
||||
-- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433
|
||||
vim.o.backupdir = vim.fn.stdpath("cache") .. "/backup"
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
if !isdirectory(&backupdir)
|
||||
call mkdir(&backupdir, "p")
|
||||
endif
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- LaTeX options
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Highlight when yanking
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Netrw
|
||||
vim.g.netrw_liststyle = 3 -- Change style to 'tree' view
|
||||
vim.g.netrw_banner = 0 -- Remove useless banner
|
||||
vim.g.netrw_winsize = 15 -- Explore window takes % of page
|
||||
vim.g.netrw_browse_split = 4 -- Open in previous window
|
||||
vim.g.netrw_altv = 1 -- Always split left
|
||||
|
||||
-- VimWiki
|
||||
vim.g.vimwiki_list = {
|
||||
{
|
||||
["path"] = "$NOTES_PATH",
|
||||
["syntax"] = "markdown",
|
||||
["index"] = "home",
|
||||
["ext"] = ".md",
|
||||
},
|
||||
}
|
||||
vim.g.vimwiki_key_mappings = {
|
||||
["all_maps"] = 1,
|
||||
["mouse"] = 1,
|
||||
}
|
||||
vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open
|
||||
vim.g.vimwiki_create_link = 0 -- Don't automatically create new links
|
||||
vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression
|
||||
vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
au FileType markdown inoremap ;tt <Esc>:AddTag<CR>
|
||||
|
||||
function! PInsert(item)
|
||||
let @z=a:item
|
||||
norm "zpx
|
||||
endfunction
|
||||
|
||||
command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')})
|
||||
]],
|
||||
false
|
||||
)
|
Loading…
Reference in New Issue
Block a user