nvim: add nvim configs
This commit is contained in:
parent
6339cdb490
commit
4446e72a04
0
dot_config/nvim/after/plugin/.keep
Normal file
0
dot_config/nvim/after/plugin/.keep
Normal file
7
dot_config/nvim/init.lua.tmpl
Normal file
7
dot_config/nvim/init.lua.tmpl
Normal file
@ -0,0 +1,7 @@
|
||||
require("core.options")
|
||||
require("core.keymaps")
|
||||
require("utils")
|
||||
|
||||
{{- if ne .chezmoi.username "root" }}
|
||||
require("lazy-setup")
|
||||
{{- end }}
|
18
dot_config/nvim/lua/core/keymaps.lua.tmpl
Normal file
18
dot_config/nvim/lua/core/keymaps.lua.tmpl
Normal file
@ -0,0 +1,18 @@
|
||||
vim.keymap.set('n', '<Esc><Esc>', '<cmd>silent nohl<CR>')
|
||||
vim.keymap.set('n', '[b', '<cmd>silent bp<CR>')
|
||||
vim.keymap.set('n', ']b', '<cmd>silent bn<CR>')
|
||||
vim.keymap.set('n', '<leader>x', ':')
|
||||
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex)
|
||||
vim.keymap.set('n', '<leader>M', '<cmd>messages<CR>')
|
||||
vim.keymap.set('n', '<leader>q', '<cmd>x<CR>')
|
||||
vim.keymap.set('n', '<leader>QQ', '<cmd>q!<CR>')
|
||||
{{- if ne .chezmoi.username "root" }}
|
||||
vim.keymap.set('n', '<leader>W', '<cmd>w !sudo -A tee %<CR>')
|
||||
{{- end }}
|
||||
vim.keymap.set('n', 'n', 'nzzzv')
|
||||
vim.keymap.set('n', 'N', 'Nzzzv')
|
||||
vim.keymap.set('n', 'G', 'Gzz')
|
||||
vim.keymap.set('n', '<C-u>', '<C-u>zz')
|
||||
vim.keymap.set('n', '<C-d>', '<C-d>zz')
|
||||
vim.keymap.set('n', '<PageUp>', '<C-u>zz')
|
||||
vim.keymap.set('n', '<PageDown>', '<C-d>zz')
|
66
dot_config/nvim/lua/core/options.lua.tmpl
Normal file
66
dot_config/nvim/lua/core/options.lua.tmpl
Normal file
@ -0,0 +1,66 @@
|
||||
{{- if (or (eq .chezmoi.hostname "arch") (eq .chezmoi.hostname "buzz")) }}
|
||||
if (vim.g.neovide) then
|
||||
vim.g.neovide_scale_factor = 0.7
|
||||
vim.g.neovide_cursor_animation_length = 0
|
||||
end
|
||||
{{- end }}
|
||||
|
||||
vim.cmd([[
|
||||
try
|
||||
if exists('+termguicolors')
|
||||
set termguicolors
|
||||
endif
|
||||
colorscheme yah
|
||||
catch
|
||||
colorscheme desert
|
||||
endtry
|
||||
]])
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
vim.cmd(":filetype plugin indent on")
|
||||
vim.cmd(":syntax enable")
|
||||
|
||||
vim.opt.backspace = "indent,eol,start"
|
||||
vim.opt.smarttab = true
|
||||
|
||||
vim.opt.ruler = true
|
||||
vim.opt.wildmenu = true
|
||||
|
||||
vim.opt.gdefault = true vim.opt.autoread = true vim.opt.history = 1000
|
||||
vim.opt.encoding = "utf-8"
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.laststatus = 2
|
||||
vim.opt.showcmd = true
|
||||
vim.opt.showmatch = true
|
||||
vim.opt.cmdheight = 3
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = "tab:>>,trail:_,eol:$,multispace:··,extends:>,precedes:<,nbsp:%"
|
||||
vim.opt.encoding = "utf-8"
|
||||
vim.opt.fenc = "utf-8"
|
||||
|
||||
{{- if eq .chezmoi.username "root" }}
|
||||
vim.opt.expandtab = false
|
||||
{{- else }}
|
||||
vim.opt.expandtab = true
|
||||
{{- end }}
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
|
||||
-- abbreviations
|
||||
vim.cmd(":ca cd. lcd %:p:h")
|
||||
vim.cmd(':ca mkdir. call mkdir(expand("%:p:h"), "p")')
|
||||
{{- if ne .chezmoi.username "root" }}
|
||||
vim.cmd(':ca W! w !sudo -A tee %')
|
||||
{{- end }}
|
||||
|
||||
{{- if (or (eq .chezmoi.hostname "arch") (eq .chezmoi.hostname "buzz")) }}
|
||||
vim.cmd([[ autocmd InsertLeave * call system("fcitx5-remote -c") ]])
|
||||
{{- end }}
|
||||
|
||||
|
||||
vim.cmd("set clipboard+=unnamedplus")
|
14
dot_config/nvim/lua/lazy-setup.lua
Normal file
14
dot_config/nvim/lua/lazy-setup.lua
Normal file
@ -0,0 +1,14 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git", "clone", "--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup("plugins")
|
||||
|
||||
vim.keymap.set("n", "<leader>L", "<cmd>Lazy<CR>", { noremap = true, silent = true })
|
6
dot_config/nvim/lua/plugins/colorizer.lua
Normal file
6
dot_config/nvim/lua/plugins/colorizer.lua
Normal file
@ -0,0 +1,6 @@
|
||||
return {
|
||||
'norcalli/nvim-colorizer.lua',
|
||||
config = function()
|
||||
require('colorizer').setup()
|
||||
end
|
||||
}
|
1
dot_config/nvim/lua/plugins/commentary.lua
Normal file
1
dot_config/nvim/lua/plugins/commentary.lua
Normal file
@ -0,0 +1 @@
|
||||
return { 'tpope/vim-commentary' }
|
6
dot_config/nvim/lua/plugins/fugitive.lua
Normal file
6
dot_config/nvim/lua/plugins/fugitive.lua
Normal file
@ -0,0 +1,6 @@
|
||||
return {
|
||||
'tpope/vim-fugitive',
|
||||
config = function()
|
||||
vim.keymap.set("n", "<leader>gg", vim.cmd.Git)
|
||||
end
|
||||
}
|
8
dot_config/nvim/lua/plugins/mini.lua
Normal file
8
dot_config/nvim/lua/plugins/mini.lua
Normal file
@ -0,0 +1,8 @@
|
||||
return {
|
||||
'echasnovski/mini.nvim',
|
||||
config = function()
|
||||
require('mini.align').setup()
|
||||
require('mini.splitjoin').setup()
|
||||
require('mini.trailspace').setup()
|
||||
end
|
||||
}
|
1
dot_config/nvim/lua/plugins/repeat.lua
Normal file
1
dot_config/nvim/lua/plugins/repeat.lua
Normal file
@ -0,0 +1 @@
|
||||
return { 'tpope/vim-repeat' }
|
2
dot_config/nvim/lua/plugins/surround.lua
Normal file
2
dot_config/nvim/lua/plugins/surround.lua
Normal file
@ -0,0 +1,2 @@
|
||||
return { 'tpope/vim-surround' }
|
||||
|
14
dot_config/nvim/lua/plugins/telescope.lua
Normal file
14
dot_config/nvim/lua/plugins/telescope.lua
Normal file
@ -0,0 +1,14 @@
|
||||
return {
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.5',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
config = function()
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>\'', builtin.marks, {})
|
||||
vim.keymap.set('n', '<leader>.', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>,.', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>,/', builtin.live_grep, {})
|
||||
vim.keymap.set('n', '<leader>,,', builtin.buffers, {})
|
||||
vim.keymap.set('n', '<leader>,;', builtin.command_history, {})
|
||||
vim.keymap.set('n', '<leader>,?', builtin.search_history, {})
|
||||
end
|
||||
}
|
63
dot_config/nvim/lua/plugins/treesitter.lua
Normal file
63
dot_config/nvim/lua/plugins/treesitter.lua
Normal file
@ -0,0 +1,63 @@
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"c_sharp",
|
||||
"cmake",
|
||||
"commonlisp",
|
||||
"cpp",
|
||||
"css",
|
||||
"diff",
|
||||
"dockerfile",
|
||||
"fish",
|
||||
"git_config",
|
||||
"gitcommit",
|
||||
"gitignore",
|
||||
"go",
|
||||
"html",
|
||||
"javascript",
|
||||
"jq",
|
||||
"json",
|
||||
"latex",
|
||||
"lua",
|
||||
"org",
|
||||
"php",
|
||||
"python",
|
||||
"query",
|
||||
"ruby",
|
||||
"rust",
|
||||
"scss",
|
||||
"todotxt",
|
||||
"toml",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"vue",
|
||||
"xml",
|
||||
"yaml",
|
||||
},
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
6
dot_config/nvim/lua/plugins/undotree.lua
Normal file
6
dot_config/nvim/lua/plugins/undotree.lua
Normal file
@ -0,0 +1,6 @@
|
||||
return {
|
||||
'mbbill/undotree',
|
||||
config = function()
|
||||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
end
|
||||
}
|
7
dot_config/nvim/lua/plugins/yah.lua
Normal file
7
dot_config/nvim/lua/plugins/yah.lua
Normal file
@ -0,0 +1,7 @@
|
||||
return {
|
||||
"inkch/vim-yah",
|
||||
lazy = false,
|
||||
config = function()
|
||||
vim.cmd[[colorscheme yah]]
|
||||
end,
|
||||
}
|
3
dot_config/nvim/lua/utils/init.lua
Normal file
3
dot_config/nvim/lua/utils/init.lua
Normal file
@ -0,0 +1,3 @@
|
||||
require("utils.zenkaku")
|
||||
require("utils.trim")
|
||||
require("utils.setindent")
|
10
dot_config/nvim/lua/utils/setindent.lua
Normal file
10
dot_config/nvim/lua/utils/setindent.lua
Normal file
@ -0,0 +1,10 @@
|
||||
-- Functions
|
||||
local setIndentWidth = function(w)
|
||||
vim.opt.tabstop = w
|
||||
vim.opt.softtabstop = w
|
||||
vim.opt.shiftwidth = w
|
||||
print("Tab width is now set", w)
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<leader>T2', function() setIndentWidth(2) end)
|
||||
vim.keymap.set('n', '<leader>T4', function() setIndentWidth(4) end)
|
27
dot_config/nvim/lua/utils/trim.lua
Normal file
27
dot_config/nvim/lua/utils/trim.lua
Normal file
@ -0,0 +1,27 @@
|
||||
-- Trim
|
||||
vim.cmd([[
|
||||
command! Trim call TrimSpace()
|
||||
function! TrimSpace()
|
||||
let save_cursor = getpos(".")
|
||||
%s#\ \+$##e
|
||||
%s#\($\n\s*\)\+\%$##e
|
||||
call setpos('.', save_cursor)
|
||||
endfunction
|
||||
|
||||
command! TrimDisable call TrimAuto(0)
|
||||
command! TrimEnable call TrimAuto(1)
|
||||
function! TrimAuto(enable)
|
||||
if a:enable == 1
|
||||
augroup TrimAuto
|
||||
au!
|
||||
au BufWritePre * Trim " See: ~/.config/nvim/functions/Trim.vim
|
||||
augroup END
|
||||
else
|
||||
augroup TrimAuto
|
||||
au!
|
||||
augroup END
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call TrimAuto(1)
|
||||
]])
|
15
dot_config/nvim/lua/utils/zenkaku.lua
Normal file
15
dot_config/nvim/lua/utils/zenkaku.lua
Normal file
@ -0,0 +1,15 @@
|
||||
-- ZenkakuSpace
|
||||
vim.cmd([[
|
||||
function! ZenkakuSpace()
|
||||
highlight ZenkakuSpace cterm=underline guibg=lightred
|
||||
endfunction
|
||||
|
||||
if has('syntax')
|
||||
augroup ZenkakuSpace
|
||||
autocmd!
|
||||
autocmd ColorScheme * call ZenkakuSpace()
|
||||
autocmd VimEnter,WinEnter,BufRead * let w:m1=matchadd('ZenkakuSpace', ' ')
|
||||
augroup END
|
||||
call ZenkakuSpace()
|
||||
endif
|
||||
]])
|
Loading…
Reference in New Issue
Block a user