navigator
spike 2 years ago
parent ac0faa4f8b
commit 1423db18ba

1
.gitignore vendored

@ -1,3 +1,2 @@
plugin
custom
spell

@ -0,0 +1 @@
../../dotfiles/nvim/.config/nvim/mysnippets

@ -1,4 +1,4 @@
-- n, v, i, t = mode names
-- n, v, i, t, c = mode name.s
local function termcodes(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
@ -8,15 +8,20 @@ local M = {}
M.general = {
i = {
-- go to beginning and end
["<C-b>"] = { "<ESC>^i", "beginning of line" },
["<C-e>"] = { "<End>", "end of line" },
["jk"] = { "<esc>", "escape"},
-- navigate within insert mode
["<C-h>"] = { "<Left>", "move left" },
["<C-l>"] = { "<Right>", "move right" },
["<C-j>"] = { "<Down>", "move down" },
["<C-k>"] = { "<Up>", "move up" },
["<C-s>"] = { "<cmd> update <CR>", "update file (save on changes)"},
-- luasnip change choice
["<C-u>"] = {"<Plug>luasnip-next-choice", "change luasnip choice"},
},
n = {
@ -28,8 +33,35 @@ M.general = {
["<C-j>"] = { "<C-w>j", "window down" },
["<C-k>"] = { "<C-w>k", "window up" },
-- Window resizing
["<C-Left>"] = { "<cmd> vert res +2 <CR>", "window width +" },
["<C-Right>"] = { "<cmd> vert res -2 <CR>", "window width -" },
["<C-Up>"] = { "<cmd>res +2 <CR>", "window height +" },
["<C-Down>"] = { "<cmd>res -2 <CR>", "window height -" },
-- quit dont save
["<leader>qq"] = {"<cmd> quitall! <cr>", "quit/close all windows, don't save"},
["Q"] = {"<cmd> q!<cr>", "quit now"},
-- easier horizontal scrolling
["zl"] = {"zL", "horizontal scroll left"},
["zh"] = {"zH", "horizontal scroll right"},
-- Use fast jump to exact location and reserve `` for other usage
["''"] = {"``", "jump back to exact location"},
-- Go to the first non-blank character of a line
["0"] = {"^"},
-- Just in case you need to go to the very beginning of a line
["^"] = {"0"},
["<leader>ww"] = { "<cmd> set wrap! <CR><cmd> echo 'wrap = '.&wrap <CR>"},
-- save
["<C-s>"] = { "<cmd> w <CR>", "save file" },
["<C-s>"] = { "<cmd> update <CR>", "save file" },
-- Copy all
["<C-c>"] = { "<cmd> %y+ <CR>", "copy whole file" },
@ -52,34 +84,98 @@ M.general = {
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
-- empty mode is same as using <cmd> :map
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["j"] = { "gj" },
["k"] = { "gk" },
-- new buffer
["<S-b>"] = { "<cmd> enew <CR>", "new buffer" },
-- new tab
["<leader><Tab>"] = {"<cmd> tabe <CR>", "new tab"},
-- Fast tab
["<S-H>"] = { "gT", "Previous tab"},
["<S-L>"] = { "gt", "Previous tab"},
-- close buffer + hide terminal buffer
["<leader>x"] = {
["<leader>xx"] = {
function()
require("core.utils").close_buffer()
end,
"close buffer",
},
["<Down>"] = {"<cmd> close <CR>", "close window"},
-- yank from cusor to eol to system and primary clipboard
["<leader>y"] = {'"*y$"+y$'},
-- folding levels
["<leader>f0"] = {":set foldlevel=0<CR>", "set fold level"},
["<leader>f1"] = {":set foldlevel=1<CR>", "set fold level"},
["<leader>f2"] = {":set foldlevel=2<CR>", "set fold level"},
["<leader>f3"] = {":set foldlevel=3<CR>", "set fold level"},
["<leader>f4"] = {":set foldlevel=4<CR>", "set fold level"},
["<leader>f5"] = {":set foldlevel=5<CR>", "set fold level"},
["<leader>f6"] = {":set foldlevel=6<CR>", "set fold level"},
["<leader>f7"] = {":set foldlevel=7<CR>", "set fold level"},
["<leader>f8"] = {":set foldlevel=8<CR>", "set fold level"},
["<leader>f9"] = {":set foldlevel=9<CR>", "set fold level"},
["<leader>en"] = {"<cmd> cn <CR>", "next error"},
["<leader>rp"] = {"<cmd> cp <CR>", "previous error"},
["g."] = {":cwd<CR>", "change dir to current file", opts = { remap = true}},
-- Packer commands
["<leader>ps"] = {"<cmd> PackerSync <CR>", "packer sync"},
-- Notify cmd watcher (see /scripts/utils/fifo_watch.sh)
["<leader><leader>,"] = {
function()
local fifo_patch="/tmp/fifo_vimnotify"
os.execute("echo do >" .. fifo_patch )
end,
"notify <scripts/utils/fifo_watch>"
}
},
t = { ["<C-x>"] = { termcodes "<C-\\><C-N>", "escape terminal mode" } },
v = {
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["j"] = { "gj" },
["k"] = { "gk" },
-- Don't copy the replaced text after pasting in visual mode
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', opts = { silent = true } },
-- yank from cursor to eol to system and primary clipboard
["<leader>y"] = {'"*y gv"+y', "yank line to clipboards"},
-- visual shifting
["<"] = {"<gv"},
[">"] = {">gv"},
-- Allow using the repeat operator with a visual selection (!)
-- http://stackoverflow.com/a/8064607/127816
["."] = {":normal .<CR>", opts = { silent = true}},
},
-- command line mappings
c = {
["Tabe"] = {"tabe"},
-- Change Working Directory to that of the current file
["cwd"] = {"lcd %:p:h", "change dir to current file"},
["cd."] = {"lcd %:p:h", "change dir to current file"},
}
}
M.tabufline = {
@ -154,7 +250,7 @@ M.lspconfig = {
"lsp hover",
},
["gi"] = {
["gm"] = {
function()
vim.lsp.buf.implementation()
end,
@ -259,10 +355,7 @@ M.nvimtree = {
n = {
-- toggle
["<C-n>"] = { "<cmd> NvimTreeToggle <CR>", "toggle nvimtree" },
-- focus
["<leader>e"] = { "<cmd> NvimTreeFocus <CR>", "focus nvimtree" },
["<Left>"] = { "<cmd> NvimTreeToggle <CR>", "toggle nvimtree" },
},
}
@ -272,16 +365,20 @@ M.telescope = {
n = {
-- find
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "find files" },
["<C-p>"] = { "<cmd> Telescope find_files <CR>", "find files" },
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "find all" },
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
["<leader>f*"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "find buffers" },
["<leader>;"] = { "<cmd> Telescope buffers <CR>", "find buffers" },
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "help page" },
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "find oldfiles" },
["<leader>tk"] = { "<cmd> Telescope keymaps <CR>", "show keys" },
-- git
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "git commits" },
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "git status" },
["<leader>tg"] = {" ", "telescope git commands"},
["<leader>tgc"] = { "<cmd> Telescope git_commits <CR>", "git commits" },
["<leader>tgs"] = { "<cmd> Telescope git_status <CR>", "git status" },
-- pick a hidden term
["<leader>pt"] = { "<cmd> Telescope terms <CR>", "pick hidden term" },
@ -401,4 +498,25 @@ M.blankline = {
},
}
-- Tagbar equivalent with LSP
M.vista = {
plugin = true,
n = {
["<Right>"] = { "<cmd> Vista!! <CR>", "toggle Vista "} ,
},
}
M.asyncrun = {
plugin = true,
n = {
["``"] = {"<cmd> call asyncrun#quickfix_toggle(8)<CR>", "toggle quickfix window"} ,
["<leader>m"] = {":AsyncRun -program=" .. vim.o.makeprg .. "<CR>", "make using asyncrun"},
["<leader><leader>r"] = {":AsyncRun ", "custom asyncrun command"},
["<leader>pd"] = {"<cmd> AsyncRun lpr -P PDF_PRINT %<CR>", "PDF print file"},
["<leader>pp"] = {"<cmd> AsyncRun lpr %<CR>"},
},
}
return M

@ -20,26 +20,71 @@ opt.showmode = false
opt.title = true
opt.clipboard = "unnamedplus"
opt.cul = true -- cursor line
opt.colorcolumn = "80"
opt.rulerformat = "%30(%=:b%n%y%m%r%w %l,%c%V %P%)" -- NvChad has custom ruler !
-- Indenting
opt.expandtab = true
opt.shiftwidth = 2
opt.smartindent = true
opt.tabstop = 2
opt.softtabstop = 2
opt.expandtab = true -- Tabs are spaces, not tabs
opt.shiftwidth = 2 -- use indents of 2 spaces
opt.smartindent = true -- smart indent when starting new lines
opt.tabstop = 2 -- number of spaces when tab pressed
opt.softtabstop = 2 -- Let backspace delete indent
-- http://vim.wikia.com/wiki/Converting_tabs_to_spaces
opt.tabpagemax = 10
opt.fillchars = { eob = " " }
opt.ignorecase = true
opt.smartcase = true
opt.mouse = "a"
opt.cpoptions:append ">" -- When appending to registers use newline
-- GUI
opt.mousehide = true
-- Numbers
opt.number = true
opt.relativenumber = true
opt.numberwidth = 2
opt.ruler = false
-- disable nvim intro
opt.shortmess:append "sI"
opt.viewoptions="folds,cursor,curdir"
opt.viewoptions:remove("options")
-- . # and - are end of word designators
opt.iskeyword:remove(".")
opt.iskeyword:remove("#")
opt.iskeyword:remove("-")
opt.foldlevelstart = 0
opt.conceallevel=1 -- how to show text with :syn-conceal syntax
opt.list = true -- show tabs,trailing spaces and non-breakable spaces
opt.listchars = "tab: ,trail:•,extends:#,nbsp:." -- Highlight problematic whitespace
opt.diffopt:append("vertical")
opt.completeopt = "menu,menuone,noselect"
opt.wrap = false
opt.formatoptions:append("b") -- Auto-wrap text based on textwidt
opt.matchpairs:append("<:>")
-- Lines to scroll when cursor leaves screen
opt.scrolljump=5
opt.scrolloff=3
-- Allow :find to work on all subdirectories
-- this only works when the original dir path is not changed
opt.path:append("**")
-- netrw file explorer (if it's used)
g.netrw_silent = 1
g.netrw_liststyle=3 -- Display more details with files
g.netrw_banner = 0 -- Remove banner at top
g.netrw_browse_split = 4 -- Open files in vertical split
g.netrw_winsize = 20 -- width of the window (25%)
opt.signcolumn = "yes"
opt.splitbelow = true
@ -48,6 +93,12 @@ opt.termguicolors = true
opt.timeoutlen = 400
opt.undofile = true
-- backups
opt.backup = true
opt.backupcopy = "yes"
opt.backupdir = vim.fn.expand("$XDG_DATA_HOME/nvim/backups")
opt.sessionoptions="blank,buffers,curdir,folds,tabpages,winsize,resize,localoptions"
-- interval for writing swap file to disk, also used by gitsigns
opt.updatetime = 250
@ -55,7 +106,7 @@ opt.updatetime = 250
-- when cursor reaches end/beginning of line
opt.whichwrap:append "<>[]hl"
g.mapleader = " "
g.mapleader = ","
-- disable some builtin vim plugins
local default_plugins = {
@ -64,10 +115,6 @@ local default_plugins = {
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",

@ -0,0 +1,22 @@
-- Just an example, supposed to be placed in /lua/custom/
local M = {}
-- make sure you maintain the structure of `core/default_config.lua` here,
-- example of changing theme:
M.ui = {
theme = "monekai",
theme_toggle = { "monekai", "blossom" },
-- hl_override = {
-- CursorLine = {
-- underline = 1
-- }
-- },
}
M.plugins = {
user = require "custom.plugins"
}
return M

@ -0,0 +1,42 @@
-- local augroup = vim.api.nvim_create_augroup
-- local autocmd = vim.api.nvim_create_autocmd
vim.cmd [[
hi CursorLine gui=underline
]]
-- Shift key typos
vim.cmd [[
command! -bang -nargs=* -complete=file E e<bang> <args>
command! -bang -nargs=* -complete=file W w<bang> <args>
command! -bang -nargs=* -complete=file Wq wq<bang> <args>
command! -bang -nargs=* -complete=file WQ wq<bang> <args>
command! -nargs=* -complete=help H h <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
]]
vim.cmd [[
" Autocompile suckless
let dwm_file_patterns = expand("$HOME/.local/src/suckless/*/{config.h,*.c}")
augroup DWM
au!
execute "au BufEnter " . dwm_file_patterns . " :lcd %:p:h"
execute "au BufWrite " . dwm_file_patterns . " :AsyncRun! make clean && make && sudo make install"
"au BufWrite */src/*/dwm*/{*.h,dwm.c} :AsyncRun! make clean && make && sudo make install
augroup END
]]
-- Make asyncrun work with fugitive
vim.cmd [[
augroup asyncrun
au!
command -bang -nargs=* -complete=file Make AsyncRun -program=make @ <args>
augroup END
]]

@ -0,0 +1,39 @@
return {
["mfussenegger/nvim-dap"] = {
module = "dap"
},
["liuchengxu/vista.vim"] = {
cmd = "Vista",
setup = function()
require("core.utils").load_mappings "vista"
end
},
["folke/which-key.nvim"] = {
disable = false,
},
-- Run async commands (make & errors)
["skywind3000/asyncrun.vim"] = {
config = function()
require("core.utils").load_mappings "asyncrun"
vim.g.asyncrun_open = 8
end
},
["L3MON4D3/LuaSnip"] = {
config = function()
-- load default config first
require("plugins.configs.others").luasnip()
vim.g.my_snippets_paths = {"./custom_snippets"}
require("luasnip").filetype_extend("markdown", { "markdown_zk" })
-- load snippets from "honza/vim-snippets"
-- includes ultisnips and snipmate snippets
require("luasnip.loaders.from_snipmate").lazy_load({ override_priority = 800 })
require("luasnip.loaders.from_snipmate").lazy_load {
paths = vim.g.my_snippets_paths,
override_priority = 800
}
end
},
["honza/vim-snippets"] = {}
}

@ -57,12 +57,36 @@ local options = {
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<C-e>"] = cmp.mapping.complete(),
["<C-c>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
-- luasnip forward jump
["<C-k>"] = cmp.mapping(function(fallback)
local luasnip = require("luasnip")
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, {
"i",
"s",
}),
-- luasnip reverse jump
["<C-j>"] = cmp.mapping(function(fallback)
local luasnip = require("luasnip")
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()

@ -71,4 +71,9 @@ lspconfig.sumneko_lua.setup {
},
}
lspconfig.gopls.setup {
on_attach = M.on_attach,
capabilities = M.capabilities,
}
return M

@ -55,8 +55,8 @@ M.blankline = function()
buftype_exclude = { "terminal" },
show_trailing_blankline_indent = false,
show_first_indent_level = false,
show_current_context = true,
show_current_context_start = true,
show_current_context = false,
show_current_context_start = false,
}
options = load_override(options, "lukas-reineke/indent-blankline.nvim")

Loading…
Cancel
Save