diff --git a/dot_config/nvim/after/plugin/.keep b/dot_config/nvim/after/plugin/.keep new file mode 100644 index 0000000..e69de29 diff --git a/dot_config/nvim/init.lua.tmpl b/dot_config/nvim/init.lua.tmpl new file mode 100644 index 0000000..b69e74e --- /dev/null +++ b/dot_config/nvim/init.lua.tmpl @@ -0,0 +1,7 @@ +require("core.options") +require("core.keymaps") +require("utils") + +{{- if ne .chezmoi.username "root" }} +require("lazy-setup") +{{- end }} diff --git a/dot_config/nvim/lua/core/keymaps.lua.tmpl b/dot_config/nvim/lua/core/keymaps.lua.tmpl new file mode 100644 index 0000000..a731167 --- /dev/null +++ b/dot_config/nvim/lua/core/keymaps.lua.tmpl @@ -0,0 +1,18 @@ +vim.keymap.set('n', '', 'silent nohl') +vim.keymap.set('n', '[b', 'silent bp') +vim.keymap.set('n', ']b', 'silent bn') +vim.keymap.set('n', 'x', ':') +vim.keymap.set('n', 'pv', vim.cmd.Ex) +vim.keymap.set('n', 'M', 'messages') +vim.keymap.set('n', 'q', 'x') +vim.keymap.set('n', 'QQ', 'q!') +{{- if ne .chezmoi.username "root" }} +vim.keymap.set('n', 'W', 'w !sudo -A tee %') +{{- end }} +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') +vim.keymap.set('n', 'G', 'Gzz') +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') diff --git a/dot_config/nvim/lua/core/options.lua.tmpl b/dot_config/nvim/lua/core/options.lua.tmpl new file mode 100644 index 0000000..bedf761 --- /dev/null +++ b/dot_config/nvim/lua/core/options.lua.tmpl @@ -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") diff --git a/dot_config/nvim/lua/lazy-setup.lua b/dot_config/nvim/lua/lazy-setup.lua new file mode 100644 index 0000000..34b31b9 --- /dev/null +++ b/dot_config/nvim/lua/lazy-setup.lua @@ -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", "L", "Lazy", { noremap = true, silent = true }) diff --git a/dot_config/nvim/lua/plugins/colorizer.lua b/dot_config/nvim/lua/plugins/colorizer.lua new file mode 100644 index 0000000..882a5f6 --- /dev/null +++ b/dot_config/nvim/lua/plugins/colorizer.lua @@ -0,0 +1,6 @@ +return { + 'norcalli/nvim-colorizer.lua', + config = function() + require('colorizer').setup() + end +} diff --git a/dot_config/nvim/lua/plugins/commentary.lua b/dot_config/nvim/lua/plugins/commentary.lua new file mode 100644 index 0000000..3ef4bb3 --- /dev/null +++ b/dot_config/nvim/lua/plugins/commentary.lua @@ -0,0 +1 @@ +return { 'tpope/vim-commentary' } diff --git a/dot_config/nvim/lua/plugins/fugitive.lua b/dot_config/nvim/lua/plugins/fugitive.lua new file mode 100644 index 0000000..47b0477 --- /dev/null +++ b/dot_config/nvim/lua/plugins/fugitive.lua @@ -0,0 +1,6 @@ +return { + 'tpope/vim-fugitive', + config = function() + vim.keymap.set("n", "gg", vim.cmd.Git) + end +} diff --git a/dot_config/nvim/lua/plugins/mini.lua b/dot_config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..e70b93c --- /dev/null +++ b/dot_config/nvim/lua/plugins/mini.lua @@ -0,0 +1,8 @@ +return { + 'echasnovski/mini.nvim', + config = function() + require('mini.align').setup() + require('mini.splitjoin').setup() + require('mini.trailspace').setup() + end +} diff --git a/dot_config/nvim/lua/plugins/repeat.lua b/dot_config/nvim/lua/plugins/repeat.lua new file mode 100644 index 0000000..bfd6742 --- /dev/null +++ b/dot_config/nvim/lua/plugins/repeat.lua @@ -0,0 +1 @@ +return { 'tpope/vim-repeat' } diff --git a/dot_config/nvim/lua/plugins/surround.lua b/dot_config/nvim/lua/plugins/surround.lua new file mode 100644 index 0000000..e89e404 --- /dev/null +++ b/dot_config/nvim/lua/plugins/surround.lua @@ -0,0 +1,2 @@ +return { 'tpope/vim-surround' } + diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..eeabcd2 --- /dev/null +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -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', '\'', builtin.marks, {}) + vim.keymap.set('n', '.', builtin.find_files, {}) + vim.keymap.set('n', ',.', builtin.find_files, {}) + vim.keymap.set('n', ',/', builtin.live_grep, {}) + vim.keymap.set('n', ',,', builtin.buffers, {}) + vim.keymap.set('n', ',;', builtin.command_history, {}) + vim.keymap.set('n', ',?', builtin.search_history, {}) + end +} diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..992e797 --- /dev/null +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -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 +} diff --git a/dot_config/nvim/lua/plugins/undotree.lua b/dot_config/nvim/lua/plugins/undotree.lua new file mode 100644 index 0000000..8e99c70 --- /dev/null +++ b/dot_config/nvim/lua/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + 'mbbill/undotree', + config = function() + vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + end +} diff --git a/dot_config/nvim/lua/plugins/yah.lua b/dot_config/nvim/lua/plugins/yah.lua new file mode 100644 index 0000000..6b02fcd --- /dev/null +++ b/dot_config/nvim/lua/plugins/yah.lua @@ -0,0 +1,7 @@ +return { + "inkch/vim-yah", + lazy = false, + config = function() + vim.cmd[[colorscheme yah]] + end, +} diff --git a/dot_config/nvim/lua/utils/init.lua b/dot_config/nvim/lua/utils/init.lua new file mode 100644 index 0000000..aa3d945 --- /dev/null +++ b/dot_config/nvim/lua/utils/init.lua @@ -0,0 +1,3 @@ +require("utils.zenkaku") +require("utils.trim") +require("utils.setindent") diff --git a/dot_config/nvim/lua/utils/setindent.lua b/dot_config/nvim/lua/utils/setindent.lua new file mode 100644 index 0000000..d863ccc --- /dev/null +++ b/dot_config/nvim/lua/utils/setindent.lua @@ -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', 'T2', function() setIndentWidth(2) end) +vim.keymap.set('n', 'T4', function() setIndentWidth(4) end) diff --git a/dot_config/nvim/lua/utils/trim.lua b/dot_config/nvim/lua/utils/trim.lua new file mode 100644 index 0000000..461def8 --- /dev/null +++ b/dot_config/nvim/lua/utils/trim.lua @@ -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) +]]) diff --git a/dot_config/nvim/lua/utils/zenkaku.lua b/dot_config/nvim/lua/utils/zenkaku.lua new file mode 100644 index 0000000..e939104 --- /dev/null +++ b/dot_config/nvim/lua/utils/zenkaku.lua @@ -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 +]])