Skip to content

Commit

Permalink
Lazy whichkey
Browse files Browse the repository at this point in the history
  • Loading branch information
zachfi committed Apr 25, 2023
1 parent ecea68c commit 543b1fd
Show file tree
Hide file tree
Showing 5 changed files with 422 additions and 202 deletions.
2 changes: 2 additions & 0 deletions vim/nvim/lua/config/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require("config.keymaps")
require("config.options")
94 changes: 94 additions & 0 deletions vim/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
local opts = { noremap = true, silent = true }

local term_opts = { silent = true }

-- Shorten function name
local keymap = vim.api.nvim_set_keymap

--Remap space as leader key
--keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = ";"
vim.g.maplocalleader = ";"

-- Modes
-- normal_mode = "n",
-- insert_mode = "i",
-- visual_mode = "v",
-- visual_block_mode = "x",
-- term_mode = "t",
-- command_mode = "c",

-- Normal --
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)

keymap("n", "<C-n>", ":tabnext<cr>", opts)
keymap("n", "<C-p>", ":tabprev<cr>", opts)
keymap("n", "<C-t>", ":tabnew<cr>", opts)
keymap("n", "<leader>t", 'a<c-r>=strftime("%FT%T%z")<CR><Esc>', opts)
keymap("n", "<S-q>", "gqap", opts)

-- Resize with arrows
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)

-- Navigate buffers
keymap("n", "<S-l>", ":bnext<CR>", opts)
keymap("n", "<S-h>", ":bprevious<CR>", opts)

-- Move text up and down
keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)

-- Reflow the current line
keymap("n", "Q", "gw<CR>", opts)

-- Insert --
-- Press jk fast to enter
-- keymap("i", "jk", "<ESC>", opts)

-- Visual --
-- Stay in indent mode
keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)

-- Move text up and down
keymap("v", "<A-j>", ":m .+1<CR>==", opts)
keymap("v", "<A-k>", ":m .-2<CR>==", opts)
keymap("v", "p", '"_dP', opts)

-- Visual Block --
-- Move text up and down
keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)

-- Terminal --
-- Better terminal navigation
-- keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
-- keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
-- keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
-- keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)

keymap("n", "<leader>T", ":TroubleToggle<CR>", opts)
keymap("n", "<leader>B", ":TagbarToggle<CR>", opts)

-- ZK
keymap("n", "<leader>zd", ':lua require("zk.commands").get("ZkNew")({ dir = "journal/daily" })<CR>', opts)
keymap("n", "<leader>zw", ':lua require("zk.commands").get("ZkNew")({ dir = "journal/weekly" })<CR>', opts)
keymap("n", "<leader>zt", ":ZkTags<CR>", opts)
keymap("n", "<leader>zo", ":ZkOrphans<CR>", opts)
keymap("n", "<leader>zr", ":ZkRecents<CR>", opts)
keymap("n", "<leader>za", ":ZkNotes<CR>", opts)
keymap("n", "<leader>zn", ":ZkNew<CR>", opts)
keymap("n", "<leader>zi", ":ZkIndex<CR>", opts)
keymap("n", "<leader>zl", ":ZkLinks<CR>", opts)
keymap("n", "<leader>zc", ":ZkCd<CR>", opts)
keymap("n", "<leader>zq", ":lua ToggleTodo()<CR>", opts)
keymap("n", "<leader>zs", ":!make -C ~/notes update<CR>", opts)
106 changes: 106 additions & 0 deletions vim/nvim/lua/config/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
local options = {
backup = false, -- creates a backup file
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
cmdheight = 2, -- more space in the neovim command line for displaying messages
completeopt = { "menuone", "noselect", "noinsert", "noselect" }, -- mostly just for cmp
conceallevel = 2, -- so that `` is visible in markdown files
fileencoding = "utf-8", -- the encoding written to a file
hlsearch = true, -- highlight all matches on previous search pattern
ignorecase = true, -- ignore case in search patterns
mouse = "a", -- allow the mouse to be used in neovim
pumheight = 10, -- pop up menu height
showmode = false, -- we don't need to see things like -- INSERT -- anymore
showtabline = 1, -- always show tabs
smartcase = true, -- smart case
smartindent = true, -- make indenting smarter again
splitbelow = true, -- force all horizontal splits to go below current window
splitright = true, -- force all vertical splits to go to the right of current window
swapfile = false, -- creates a swapfile
termguicolors = true, -- set term gui colors (most terminals support this)
timeoutlen = 500, -- time to wait for a mapped sequence to complete (in milliseconds)
undofile = true, -- enable persistent undo
updatetime = 250, -- faster completion (4000ms default)
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
expandtab = true, -- convert tabs to spaces
shiftwidth = 2, -- the number of spaces inserted for each indentation
tabstop = 2, -- insert 2 spaces for a tab
cursorline = true, -- highlight the current line
number = true, -- set numbered lines
relativenumber = false, -- set relative numbered lines
numberwidth = 4, -- set number column width to 2 {default 4}
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
wrap = true, -- display lines as one long line
scrolloff = 8, -- is one of my fav
sidescrolloff = 8,
guifont = "Berkeley Mono:h12", -- the font used in graphical neovim applications
background = "dark",
list = false,
}

for k, v in pairs(options) do
vim.opt[k] = v
end

vim.opt.listchars:append("tab:»·")
vim.opt.listchars:append("trail:·")

--
--
--
--
--
-- This file is automatically loaded by plugins.config
--vim.g.mapleader = " "
--vim.g.maplocalleader = " "

--local opt = vim.opt

-- opt.autowrite = true -- Enable auto write
-- opt.clipboard = "unnamedplus" -- Sync with system clipboard
-- opt.completeopt = "menu,menuone,noselect"
-- opt.conceallevel = 3 -- Hide * markup for bold and italic
-- opt.confirm = true -- Confirm to save changes before exiting modified buffer
-- opt.cursorline = true -- Enable highlighting of the current line
-- opt.expandtab = true -- Use spaces instead of tabs
-- opt.formatoptions = "jcroqlnt" -- tcqj
-- opt.grepformat = "%f:%l:%c:%m"
-- opt.grepprg = "rg --vimgrep"
-- opt.ignorecase = true -- Ignore case
-- opt.inccommand = "nosplit" -- preview incremental substitute
-- opt.laststatus = 0
-- opt.list = true -- Show some invisible characters (tabs...
-- opt.mouse = "a" -- Enable mouse mode
-- opt.number = true -- Print line number
-- opt.pumblend = 10 -- Popup blend
-- opt.pumheight = 10 -- Maximum number of entries in a popup
-- opt.relativenumber = true -- Relative line numbers
-- opt.scrolloff = 4 -- Lines of context
-- opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
-- opt.shiftround = true -- Round indent
-- opt.shiftwidth = 2 -- Size of an indent
-- opt.shortmess:append({ W = true, I = true, c = true })
-- opt.showmode = false -- Dont show mode since we have a statusline
-- opt.sidescrolloff = 8 -- Columns of context
-- opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
-- opt.smartcase = true -- Don't ignore case with capitals
-- opt.smartindent = true -- Insert indents automatically
-- opt.spelllang = { "en" }
-- opt.splitbelow = true -- Put new windows below current
-- opt.splitright = true -- Put new windows right of current
-- opt.tabstop = 2 -- Number of spaces tabs count for
-- opt.termguicolors = true -- True color support
-- opt.timeoutlen = 300
-- opt.undofile = true
-- opt.undolevels = 10000
-- opt.updatetime = 200 -- Save swap file and trigger CursorHold
-- opt.wildmode = "longest:full,full" -- Command-line completion mode
-- opt.winminwidth = 5 -- Minimum window width
-- opt.wrap = false -- Disable line wrap
--
-- if vim.fn.has("nvim-0.9.0") == 1 then
-- opt.splitkeep = "screen"
-- opt.shortmess:append({ C = true })
-- end
--
-- -- Fix markdown indentation settings
-- vim.g.markdown_recommended_style = 0
Loading

0 comments on commit 543b1fd

Please sign in to comment.