-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(neovim): split from Vim & revamp configuration
Neovim has acquired many features and diverged quite a bit from Vim over the past few years that it was worth revisiting the configuration. - Migrate configuration from Vim Script to Lua - Use Home Manager for plugin management - Prefer built-in Neovim features over external plugins - Make use of TreeSitter and built-in LSP
- Loading branch information
1 parent
6c42706
commit df379f5
Showing
14 changed files
with
497 additions
and
12 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
local augroup = vim.api.nvim_create_augroup("vimrc", { clear = true }) | ||
|
||
-- {{{ General | ||
|
||
vim.opt.backup = true | ||
vim.opt.backupdir:remove(".") | ||
vim.opt.undofile = true | ||
vim.opt.ignorecase = true | ||
vim.opt.smartcase = true | ||
|
||
vim.g.tex_flavor = "latex" | ||
|
||
vim.cmd("silent! packadd! cfilter") | ||
|
||
-- See :h :DiffOrig | ||
vim.cmd([[ | ||
command! DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | ||
\ | wincmd p | diffthis | ||
]]) | ||
|
||
-- }}} | ||
-- {{{ Editing | ||
|
||
vim.opt.expandtab = true | ||
vim.opt.shiftwidth = 2 | ||
vim.opt.softtabstop = 2 | ||
vim.opt.copyindent = true | ||
vim.opt.preserveindent = true | ||
vim.opt.formatoptions:append({ "m", "B" }) | ||
vim.opt.fileencodings = { | ||
"ucs-bom", | ||
"utf-8", | ||
"iso-2022-jp", | ||
"euc-jp", | ||
"cp932", | ||
"default", | ||
"latin1", | ||
} | ||
|
||
-- jump to the last known cursor position | ||
vim.api.nvim_create_autocmd("BufReadPost", { | ||
group = augroup, | ||
callback = function(opts) | ||
local ft = vim.bo[opts.buf].filetype | ||
local line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1] | ||
local in_range = 1 < line and line <= vim.api.nvim_buf_line_count(opts.buf) | ||
|
||
if in_range and not ft:match("commit") then | ||
vim.api.nvim_feedkeys([[g`"]], "nx", false) | ||
end | ||
end, | ||
}) | ||
|
||
-- }}} | ||
-- {{{ UI | ||
|
||
vim.opt.colorcolumn = "81" | ||
vim.opt.foldenable = false | ||
vim.opt.inccommand = "split" | ||
vim.opt.lazyredraw = true | ||
vim.opt.mouse = "a" | ||
vim.opt.number = true | ||
vim.opt.showmatch = true | ||
vim.opt.title = true | ||
vim.opt.wildignorecase = true | ||
vim.opt.diffopt = { | ||
"internal", | ||
"filler", | ||
"closeoff", | ||
"algorithm:histogram", | ||
"indent-heuristic", | ||
} | ||
|
||
vim.api.nvim_create_autocmd("TextYankPost", { | ||
group = augroup, | ||
pattern = "*", | ||
callback = function(args) | ||
vim.highlight.on_yank({ | ||
higroup = "Visual", | ||
timeout = 300, | ||
}) | ||
end, | ||
}) | ||
|
||
vim.api.nvim_create_autocmd("QuickfixCmdPost", { | ||
group = augroup, | ||
pattern = [[\C[^lA-Z]*]], | ||
command = "botright cwindow", | ||
}) | ||
|
||
vim.api.nvim_create_autocmd("QuickfixCmdPost", { | ||
group = augroup, | ||
pattern = "l*", | ||
command = "botright lwindow", | ||
}) | ||
|
||
-- }}} | ||
-- {{{ Keybindings | ||
|
||
vim.g.mapleader = " " | ||
vim.g.maplocalleader = "\\" | ||
|
||
vim.keymap.set("n", "<Leader>b", "<Cmd>bmodified<CR>") | ||
|
||
vim.keymap.set({ "i", "s" }, "<Tab>", function() | ||
if vim.snippet.active({ direction = 1 }) then | ||
return "<Cmd>lua vim.snippet.jump(1)<CR>" | ||
else | ||
return "<Tab>" | ||
end | ||
end, { expr = true }) | ||
|
||
vim.keymap.set({ "i", "s" }, "<S-Tab>", function() | ||
if vim.snippet.active({ direction = -1 }) then | ||
return "<Cmd>lua vim.snippet.jump(-1)<CR>" | ||
else | ||
return "<S-Tab>" | ||
end | ||
end, { expr = true }) | ||
|
||
-- find merge conflict marker | ||
vim.keymap.set({ "n", "x", "o" }, "<Leader>fc", [[/\v^[<=>]{7}( .*<Bar>$)<CR>]]) | ||
-- find whitespace errors | ||
vim.keymap.set({ "n", "x", "o" }, "<Leader>f ", [[/\s\+$\<Bar> \+\ze\t<CR>]]) | ||
-- find full-width punctuation marks | ||
vim.keymap.set({ "n", "x", "o" }, "<Leader>f.", [[/\v(\.<Bar>.<Bar>。)<CR>]]) | ||
vim.keymap.set({ "n", "x", "o" }, "<Leader>f,", [[/\v(,<Bar>,<Bar>、)<CR>]]) | ||
vim.keymap.set({ "n", "x", "o" }, "<Leader>f!", [[f! /\v(!<Bar>!)<CR>]]) | ||
vim.keymap.set({ "n", "x", "o" }, "<Leader>f!", [[f? /\v(\?<Bar>?)<CR>]]) | ||
|
||
-- text objects | ||
vim.keymap.set("x", "al", "<Esc>0v$") | ||
vim.keymap.set("o", "al", "<Cmd>normal! 0v$<CR>") | ||
vim.keymap.set("x", "il", "<Esc>^vg_") | ||
vim.keymap.set("o", "il", "<Cmd>normal! ^vg_<CR>") | ||
vim.keymap.set("x", "ag", "gg0oG$") | ||
vim.keymap.set("o", "ag", [[<Cmd>exe "normal! m`"<Bar>keepjumps normal! ggVG<CR>]]) | ||
|
||
-- toggles | ||
vim.keymap.set("n", "<Leader>ts", "<Cmd>setlocal spell! spell?<CR>") | ||
vim.keymap.set("n", "<Leader>tv", "<Cmd>call vimrc#toggle_virtualedit()<CR>") | ||
vim.keymap.set("n", "<Leader>tq", "<Cmd>call vimrc#toggle_textwidth()<CR>") | ||
vim.keymap.set("n", "<Leader>t#", "<Cmd>setlocal relativenumber! relativenumber?<CR>") | ||
vim.keymap.set("n", "<Leader>t ", "<Cmd>call vimrc#toggle_whitespace_check()<CR>") | ||
vim.keymap.set("n", "<Leader>t<Tab>", "<Cmd>call vimrc#toggle_whitespace_visibility()<CR>") | ||
|
||
-- 3-way merge | ||
vim.keymap.set("n", "<Leader>1", "<Cmd>diffget LOCAL<CR>") | ||
vim.keymap.set("n", "<Leader>2", "<Cmd>diffget BASE<CR>") | ||
vim.keymap.set("n", "<Leader>3", "<Cmd>diffget REMOTE<CR>") | ||
|
||
-- }}} | ||
|
||
-- vim:set foldmethod=marker: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
if !empty(mapcheck('q', 'n')) | ||
nunmap <buffer> q | ||
endif | ||
|
||
let b:editorconfig = v:false |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ in | |
}; | ||
}; | ||
}; | ||
default = { }; | ||
description = "Install the specified vim plugins."; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
./development.nix | ||
./fonts.nix | ||
./macos.nix | ||
./neovim.nix | ||
./web.nix | ||
]; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.