diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua new file mode 100644 index 0000000..20ec5ab --- /dev/null +++ b/home/.config/nvim/init.lua @@ -0,0 +1,7 @@ +require "base" +require "theme" +require "mappings" +require "abbreviations" +require "autocmd" +require "plugins" + diff --git a/home/.config/nvim/init.vim b/home/.config/nvim/init.vim deleted file mode 100644 index a3eb04a..0000000 --- a/home/.config/nvim/init.vim +++ /dev/null @@ -1,14 +0,0 @@ -" Let init.vim handle sourcing other more specific -" vim configuration files, rather than keeping everything -" in a single huge config file - -let config_dir = system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim"') -let rc_dir = config_dir.'/rc' -execute 'source '.rc_dir.'/base.vim' -execute 'source '.rc_dir.'/mappings.vim' -execute 'source '.rc_dir.'/abbreviations.vim' -execute 'source '.rc_dir.'/autocmd.vim' -execute 'source '.rc_dir.'/plugins.vim' -" Needs to be below plugins for colorscheme -execute 'source '.rc_dir.'/theme.vim' - diff --git a/home/.config/nvim/lua/abbreviations.lua b/home/.config/nvim/lua/abbreviations.lua new file mode 100644 index 0000000..2438046 --- /dev/null +++ b/home/.config/nvim/lua/abbreviations.lua @@ -0,0 +1,45 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- I'm not aware of abbreviations having direct lua support like mappings, +-- though I'm not certain on that and may be completely wrong, if there is +-- a better way, this is opened to pull requests. +-- TODO: Check direct abbrev lua support + +-- Make these function definitions global as they could be reused +-- in plugin specific scripts or in other places. +function abbrev(mode, input, result, reabbrev) + -- Assume noreabbrev unless specified otherwise + reabbrev = reabbrev or false + local command + if reabbrev then + command = mode .. "abbrev" + else + command = mode .. "noreabbrev" + end + cmd(command .. " " .. input .. " " .. result) +end + +function cabbrev(input, result, reabbrev) + abbrev("c", input, result, reabbrev) +end + +-- Invalid case abbreviations +cabbrev("Wq", "wq") +cabbrev("wQ", "wq") +cabbrev("WQ", "wq") +cabbrev("Wa", "wa") +cabbrev("W", "w") +cabbrev("Q", "q") +cabbrev("Qall", "qall") +cabbrev("W!", "w!") +cabbrev("Q!", "q!") +cabbrev("Qall!", "qall!") + +-- Save file with sudo +cabbrev("w!!", "w !sudo tee > /dev/null %") + +-- Reload lua configuration +-- TODO: Get the path dynamically +cabbrev("reload", "luafile ~/.config/nvim/init.lua") + diff --git a/home/.config/nvim/lua/autocmd.lua b/home/.config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..f98eefb --- /dev/null +++ b/home/.config/nvim/lua/autocmd.lua @@ -0,0 +1,21 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- Disable automatic commenting on newlines +cmd[[autocmd FileType * setlocal formatoptions-=cro]] + +-- Have vim jump to last position when reopening a file +cmd[[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]] + +-- Automatically delete all trailing whitespace on save +cmd[[autocmd BufWritePre * %s/\s\+$//e]] + +-- Enable spellcheck for certain file types +cmd[[autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us]] + +-- Use auto-wrap for certain file types at 119 chars +cmd[[autocmd FileType markdown setlocal textwidth=119]] + +-- Don't show line numbers in terminal +cmd[[autocmd BufEnter term://* setlocal nonumber | setlocal norelativenumber]] + diff --git a/home/.config/nvim/lua/base.lua b/home/.config/nvim/lua/base.lua new file mode 100644 index 0000000..5b831c7 --- /dev/null +++ b/home/.config/nvim/lua/base.lua @@ -0,0 +1,44 @@ +local vim = require("vim") +local cmd = vim.cmd +local o = vim.opt + +cmd[[filetype plugin on]] + +-- Tab settings +o.expandtab = true -- Expand tabs to spaces +o.tabstop = 4 -- Tab size +o.shiftwidth = 4 -- Indentation size +o.softtabstop = 4 -- Tabs/Spaces interlop +o.tabpagemax = 50 -- More tabs + +-- Folding +o.foldmethod = "indent" -- Use indent to determine the fold levels +o.foldnestmax = 8 -- Only fold up to given amount of levels +o.foldlevel = 2 -- Set initial fold level +o.foldenable = false -- Hide all folds by default + +-- Split order +o.splitbelow = true -- Put new windows below current +o.splitright = true -- Put new vertical splits to right + +-- In-file search (/) +o.ignorecase = true -- Use case insensitive matching +o.incsearch = true -- Show partial matches for search phrase +o.hlsearch = true -- Highlight search matches + +-- Show trailing whitespace +o.list = true -- Enable showing characters like , , ... +o.listchars = "trail:·" -- Only show trailing whitespaces + +-- Command-mode search +o.wildmode = {"longest", "list", "full"} -- Enable autocompletion +o.wildmenu = true -- Display all matching files when we tab complete +table.insert(o.path, "**") -- Search down into subfolders with tab completion + +-- Misc +o.mouse = "a" -- Enable mouse mode +o.encoding = "utf-8" -- Use UTF-8 encoding +o.autoindent = true -- Enable autoindent +o.autoread = true -- Automatically reload files on change +o.undolevels = 999 -- Lots of these +o.history = 1000 -- More history diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..346e91a --- /dev/null +++ b/home/.config/nvim/lua/mappings.lua @@ -0,0 +1,112 @@ +local vim = require("vim") + +-- Make these function definitions global as they could be reused +-- in plugin specific scripts or in other places. +function keymap(mode, shortcut, command, options) + -- Assume silent, noremap unless specified otherwise + local opts = {noremap=true, silent=true} + if options then opts = vim.tbl_extend("force", opts, options) end + -- Perform the actual remap + vim.api.nvim_set_keymap(mode, shortcut, command, opts) +end + +-- This is a bit silly, but I don't like passing the mode argument +-- to every keymap definition and this makes things a lot easier +-- and a bit more vimscript-like +function nmap(shortcut, command, options) + keymap("n", shortcut, command, options) +end + +function imap(shortcut, command, options) + keymap("i", shortcut, command, options) +end + +function vmap(shortcut, command, options) + keymap("v", shortcut, command, options) +end + +function tmap(shortcut, command, options) + keymap("t", shortcut, command, options) +end + +-- Unmap arrow keys in normal mode to remove bad habits +nmap("", "") +nmap("", "") +nmap("", "") +nmap("", "") + +-- Tab navigation +nmap("", "gt") +nmap("", "gT") +nmap("", ":tabnew") +nmap("", ":tabmove +") +nmap("", ":tabmove -") +nmap("", ":tabp") +nmap("", ":tabn") + +-- Set splits navigation to just ALT + hjkl +nmap("", "h") +nmap("", "j") +nmap("", "k") +nmap("", "l") + +-- Split size adjusting +nmap("", ":verical resize +3") +nmap("", ":vertical resize -3") +nmap("", ":resize +3") +nmap("", ":resize -3") + +-- Define some common shortcuts +nmap("", ":w") +nmap("", ":undo") +nmap("", ":redo") + +-- Terminal +nmap("", ":split term://zshi") +nmap("", ":vnew term://zshi") +nmap("", ":tabnew term://zshi") +tmap("", "") + +-- Use space for folding/unfolding sections +nmap("", "za") +vmap("", "zf") + +-- Use shift to quickly move 10 lines up/down +nmap("K", "10k") +nmap("J", "10j") + +-- Enable/Disable auto commenting +nmap("c", ":setlocal formatoptions-=cro") +nmap("C", ":setlocal formatoptions+=cro") + +-- Don't leave visual mode after indenting +vmap("<", "", ">gv") + +-- System clipboard copying +vmap("", '"+y') + +-- Alias replace all +nmap("", ":%s//gI", {silent=false}) + +-- Stop search highlight with Esc +nmap("", ":noh") + +-- Start spell-check +nmap("s", ":setlocal spell! spelllang=en_us") + +-- Run shell check +nmap("p", ":!shellckeck %") + +-- Compile opened file (using custom script) +nmap("", ":w | !comp %") + +-- Close all opened buffers +nmap("Q", ":bufdo bdelete") + +-- Don't set the incredibely annoying mappings that trigger dynamic SQL +-- completion with dbext and keeps on freezing vim whenever pressed with +-- a message saying that dbext plugin isn't installed +-- See :h ft-sql.txt +vim.g.omni_sql_no_default_maps = 1 + diff --git a/home/.config/nvim/lua/plugins.d/airline.lua b/home/.config/nvim/lua/plugins.d/airline.lua new file mode 100644 index 0000000..8c3ef46 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/airline.lua @@ -0,0 +1,42 @@ +local vim = require("vim") +local g = vim.g +local cmd = vim.cmd + +cmd[[ +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +]] + +-- Airline specific theming settings +g.airline_theme = 'codedark' -- Use codedark theme from vim-airline-themes +g.airline_right_sep = "" -- Don't use special separators (<) +g.airline_left_sep = "" -- Don't use special separators (>) + +-- Tabline setup +-- TODO: Figure out how to set # separated variables in lua (open for PRs) +cmd[[let g:airline#extensions#tabline#enabled = 1]] -- Enable tabline (top line) +cmd[[let g:airline#tabline#formatter = 'unique_tail']] -- Tabline filename formatter + +-- Special symbols +g.webdevicons_enable_airline_statusline = 0 -- Use special icons from vim-devicons (requires nerdfonts) +g.airline_powerline_fonts = 1 -- Use special symbols from poweline fonts (line no, col no) +if not os.getenv("DISPLAY") then -- Use ASCII-only if we're in TTY + g.airline_symbols_ascii = 1 +end + +-- Disable airline in nerdtree buffer +-- TODO; For some reason, this fails even though it works in regular vimscript +--[[ +cmd[[ +augroup filetype_nerdtree + au! + au FileType nerdtree call s:disable_airline_on_nerdtree() + au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() +augroup END + +fu s:disable_airline_on_nerdtree() abort + let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 + call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) +endfu +]] +--]] diff --git a/home/.config/nvim/rc/plugins.d/coc.vim b/home/.config/nvim/lua/plugins.d/coc.vim similarity index 82% rename from home/.config/nvim/rc/plugins.d/coc.vim rename to home/.config/nvim/lua/plugins.d/coc.vim index f9d4d00..752a957 100644 --- a/home/.config/nvim/rc/plugins.d/coc.vim +++ b/home/.config/nvim/lua/plugins.d/coc.vim @@ -1,7 +1,18 @@ +" Converting these settings into lua isn't easy since we utilize +" which needs to be in a vim script context, making it impossible +" to replicate with simple vim.cmd call. It also contains a lot of function +" definitions taken from the coc github page without provided lua alternatives +" this makes it quite complicated to replicate this in pure lua, +" however if anyone knows how to completely reproduce everything here in lua, +" this is open to pull requests + +Plug 'neoclide/coc.nvim', {'branch': 'release'} + let g:coc_global_extensions = [ - \ 'coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css', + \ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css', \ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', - \ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs' + \ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs', + \ 'coc-lua' \ ] " Use tab for trigger completion with characters ahead and navigate. @@ -46,7 +57,7 @@ function! s:show_documentation() endfunction " Remap for rename current word -nmap (coc-rename) +nmap rn (coc-rename) " Remap for format selected region xmap f (coc-format-selected) diff --git a/home/.config/nvim/lua/plugins.d/commentary.lua b/home/.config/nvim/lua/plugins.d/commentary.lua new file mode 100644 index 0000000..e20acac --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/commentary.lua @@ -0,0 +1,9 @@ +local vim = require("vim") +local cmd = vim.cmd + +cmd[[Plug 'tpope/vim-commentary']] + +nmap("", ":Commentary") +vmap("", ":Commentary") + +cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] diff --git a/home/.config/nvim/lua/plugins.d/fzf.vim b/home/.config/nvim/lua/plugins.d/fzf.vim new file mode 100644 index 0000000..575e211 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/fzf.vim @@ -0,0 +1,22 @@ +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'stsewd/fzf-checkout.vim' + +let g:fzf_layout = { 'up': '~90%', 'window': { 'width': 0.8, 'height': 0.8, 'yoffset':0.5, 'xoffset': 0.5 } } +let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' + +" Customise the Files command to use ripgrep which respects .gitignore files +command! -bang -nargs=? -complete=dir Files + \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) + +" Add an AllFiles variation that shows ignored files too +command! -bang -nargs=? -complete=dir AllFiles + \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) + +nmap f :Files +nmap F :AllFiles +nmap b :Buffers +nmap h :History +nmap r :Rg +nmap R :Rg +nmap gb :GBranches diff --git a/home/.config/nvim/lua/plugins.d/nerdtree.lua b/home/.config/nvim/lua/plugins.d/nerdtree.lua new file mode 100644 index 0000000..bc83d36 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/nerdtree.lua @@ -0,0 +1,65 @@ +local vim = require("vim") +local g = vim.g +local fn = vim.fn +local cmd = vim.cmd + +cmd[[ +Plug 'preservim/nerdtree' +Plug 'Xuyuanp/nerdtree-git-plugin' +Plug 'tiagofumo/vim-nerdtree-syntax-highlight' +]] + +-- Implement manual NERDTreeToggle, but use NERDTreeFind for openning. +-- This makes NERDTree open with the current file pre-selected +nmap("", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) + +g.NERDTreeShowHidden = 1 +g.NERDTreeMinimalUI = 1 +g.NERDTreeShowLineNumbers = 0 +g.NERDTreeWinSize = 25 + +g.NERDTreeDirArrowExpandable = '►' +g.NERDTreeDirArrowCollapsible = '▼' + +-- Disable devicons for nerdtree in TTY +if not os.getenv("DISPLAY") then + g.webdevicons_enable_nerdtree = 0 +else + g.DevIconsEnableFoldersOpenClose = 1 +end + +-- If a directory is specified, start NERDTree +cmd[[ +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | + \ endif +]] + +-- Exit Vim if NERDTree is the only window left. +cmd[[ +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif +]] + +-- If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. +cmd[[ +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif +]] + +-- Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file +local bookmark_loc = os.getenv("NERDTREE_BOOKMARKS") +if bookmark_loc then + -- Check if file exists (lua doesn't have a built-in function for this) + local file_exists = os.rename(bookmark_loc, bookmark_loc) and true or false + + if not file_exists then + -- While this is possible with os.execute in lua, we would need to do some hacky + -- things to capture output from os.execute and it's simpler to just use vimscript + local dir = fn.system("dirname $NERDTREE_BOOKMARKS") + fn.system({"mkdir", "-p", dir}) + fn.system("touch $NERDTREE_BOOKMARKS") + end + g.NERDTreeBookmarksFile = bookmark_loc +end diff --git a/home/.config/nvim/lua/plugins.d/vim-code-dark.lua b/home/.config/nvim/lua/plugins.d/vim-code-dark.lua new file mode 100644 index 0000000..de7fc35 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/vim-code-dark.lua @@ -0,0 +1,12 @@ +local vim = require("vim") +local cmd = vim.cmd + +cmd[[Plug 'tomasiser/vim-code-dark']] + +-- Set vim-code-dark as colortheme after plugin loading was finished +cmd[[ +augroup VimCodeDark + autocmd! + autocmd User PlugLoaded ++nested colorscheme codedark +augroup end +]] diff --git a/home/.config/nvim/lua/plugins.d/vimwiki.lua b/home/.config/nvim/lua/plugins.d/vimwiki.lua new file mode 100644 index 0000000..8f266e5 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/vimwiki.lua @@ -0,0 +1,14 @@ +local vim = require("vim") +local cmd = vim.cmd +local g = vim.g + +cmd[[Plug 'vimwiki/vimwiki']] + +local wiki_conf = {} +wiki_conf["path"] = "~/Personal/vimwiki" +wiki_conf["path_html"] = "~/Personal/vimwiki-html" +wiki_conf["html_template"] = "~/Personal/vimwiki-html/template.tpl" +wiki_conf["syntax"] = "markdown" +wiki_conf["ext"] = ".md" +g.vimwiki_list = {wiki_conf} + diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..79ff1e7 --- /dev/null +++ b/home/.config/nvim/lua/plugins.lua @@ -0,0 +1,56 @@ +local vim = require("vim") +local cmd = vim.cmd +local fn = vim.fn + +local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim) +local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim +local plugin_files_dir = config_dir .. "/lua/plugins.d" -- Dir with plugin config files including Plug call(s) + +-- Automatically download vimplug and run PlugInstall +local autoload_dir = config_dir .. "/autoload" +local plug_install_path = autoload_dir .. "/plug.vim" +local plug_download_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" + +if fn.empty(fn.glob(plug_install_path)) > 0 then + print("Downloading vim-plug, there may be initial errors...") + fn.system({"mkdir", "-p", autoload_dir}) + fn.system("curl " .. plug_download_url .. " > " .. plug_install_path) + cmd[[autocmd VimEnter * PlugInstall]] +end + +-- Load a .vim or .lua file containing Plug call(s) and plugin settings +local function load_plugin_file(plugin_file) + local extension = plugin_file:match("^.+(%..+)$") + local plugin_path = plugin_files_dir .. "/" .. plugin_file + local run_cmd + if (extension == ".vim") then run_cmd = "source" else run_cmd = "luafile" end + fn.execute(run_cmd .. " " .. plugin_path) +end + +-- Load a single given plugin using a Plug call +local function load_plugin(plugin) + cmd("Plug '" .. plugin .. "'") +end + +-- Begin Plug.vim loading process +cmd("call plug#begin('" .. plugvim_plugins_dir .. "')") + +load_plugin('airblade/vim-gitgutter') +load_plugin('dhruvasagar/vim-table-mode') +load_plugin('tmhedberg/SimpylFold') +load_plugin('wakatime/vim-wakatime') +load_plugin('mhinz/vim-startify') +load_plugin('ryanoasis/vim-devicons') +load_plugin_file("vim-code-dark.lua") +load_plugin_file("commentary.lua") +load_plugin_file("coc.vim") +load_plugin_file("vimwiki.lua") +load_plugin_file("nerdtree.lua") +load_plugin_file("airline.lua") +load_plugin_file("fzf.vim") + +-- End Plug.vim loading process +cmd[[call plug#end()]] + +-- Run autocmds defined in the plugin files after plugin loading has finished +cmd[[doautocmd User PlugLoaded]] diff --git a/home/.config/nvim/lua/theme.lua b/home/.config/nvim/lua/theme.lua new file mode 100644 index 0000000..7cfa568 --- /dev/null +++ b/home/.config/nvim/lua/theme.lua @@ -0,0 +1,27 @@ +local vim = require("vim") +local cmd = vim.cmd +local o = vim.opt + +cmd[[syntax on]] -- Turn on syntax highlighting + +o.cursorline = true -- Highlight cursor line +o.laststatus = 2 -- Always show status line +o.number = true -- Show line numbers +o.relativenumber = true -- Use relative line numbers +o.showmatch = true -- Show matching bracket +o.scrolloff = 5 -- Keep 5 lines horizontal scrolloff +o.sidescrolloff = 5 -- Keep 5 chars vertical scrolloff + +-- I wasn't able to find a way to set guioptions directly in lua +cmd[[ +set guioptions-=m " Remove menubar +set guioptions-=T " Remove toolbar +set guioptions-=r " Remove right-hand scrollbar +set guioptions-=L " Remove left-hand scrollbar +]] + +-- Use more noticable cursor line color +cmd[[highlight CursorLine guibg=#2b2b2b]] + +-- Don't use true colors in TTY +o.termguicolors = os.getenv("DISPLAY") and true or false diff --git a/home/.config/nvim/lua/vim.lua b/home/.config/nvim/lua/vim.lua new file mode 100644 index 0000000..2bfb110 --- /dev/null +++ b/home/.config/nvim/lua/vim.lua @@ -0,0 +1,7 @@ +-- This file is here to allow running `local vim = require("vim")`, which +-- avoids the hassle of having to ignore vim as undefined-global for lua +-- language server diagnostics. Another advantage is that it actually allows +-- us to detect the attributes of vim so we will get suggestions. + +---@diagnostic disable-next-line:undefined-global +return vim diff --git a/home/.config/nvim/rc/abbreviations.vim b/home/.config/nvim/rc/abbreviations.vim deleted file mode 100644 index 69019a6..0000000 --- a/home/.config/nvim/rc/abbreviations.vim +++ /dev/null @@ -1,11 +0,0 @@ -cnoreabbrev Wq wq -cnoreabbrev wQ wq -cnoreabbrev WQ wq -cnoreabbrev Wa wa -cnoreabbrev W w -cnoreabbrev Q q -cnoreabbrev Qall qall -cnoreabbrev W! w! -cnoreabbrev Q! q! -cnoreabbrev Qall! qall! - diff --git a/home/.config/nvim/rc/autocmd.vim b/home/.config/nvim/rc/autocmd.vim deleted file mode 100644 index a7902d3..0000000 --- a/home/.config/nvim/rc/autocmd.vim +++ /dev/null @@ -1,17 +0,0 @@ -" Move ~/.viminfo to XDG_CACHE_HOME -"set viminfofile=$XDG_CACHE_HOME/vim/viminfo - -" Disable automatic commenting on newline -autocmd FileType * setlocal formatoptions-=cro - -" Have Vim jump to the last position when reopening a file -autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif - -" Automatically deletes all trailing whitespace on save -autocmd BufWritePre * %s/\s\+$//e - -" Enable spellcheck for certain file types -autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us - -" Use automatic text wrapping at 119 characters for certain file types -autocmd FileType markdown setlocal textwidth=119 diff --git a/home/.config/nvim/rc/base.vim b/home/.config/nvim/rc/base.vim deleted file mode 100644 index 799789e..0000000 --- a/home/.config/nvim/rc/base.vim +++ /dev/null @@ -1,35 +0,0 @@ -filetype plugin on " Enable filetype detection - -" Tab settings -set expandtab " Expand tabs to spaces -set tabstop=4 " Tab size -set shiftwidth=4 " Indentation size -set softtabstop=4 " Tabs/Spaces interrop -set tabpagemax=50 " More tabs - -" In-file Search (/) -set ignorecase " Do case insensitive matching -set incsearch " Show partial matches for a search phrase -set hlsearch " Highlight Search - -" Command-mode search -set path+=** " Search down into subfolders with tab completion -set wildmode=longest,list,full " Enable autocompletion -set wildmenu " Display all matching files when we tab complete - -" Folding -set foldmethod=indent " Use indent to determine the fold levels -set foldnestmax=8 " Only fold up to given amount of levels -set foldlevel=2 " Set initial fold level -set nofoldenable " Hide all folds by default - - -" Misc -set autoindent " Enable autoindent -set autoread " Reload files on change -set undolevels=999 " Lots of these -set history=1000 " More history -set encoding=utf-8 " Use UTF-8 encoding -set mouse=a " Enable mouse mode -set splitbelow splitright " Split in more natural way - diff --git a/home/.config/nvim/rc/mappings.vim b/home/.config/nvim/rc/mappings.vim deleted file mode 100644 index 65e1935..0000000 --- a/home/.config/nvim/rc/mappings.vim +++ /dev/null @@ -1,84 +0,0 @@ -" Unmap arrow keys in normal mode to remove bad habits -nnoremap -nnoremap -nnoremap -nnoremap - -" Tab navigation -nnoremap gt -nnoremap gT -nnoremap :tabnew -nnoremap :tabmove + -nnoremap :tabmove - -nnoremap :tabp -nnoremap :tabn - -" Splits navigation to just ALT + hjkl -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -" Make adjusting split sizes a bit more friendly -noremap :vertical resize +3 -noremap :vertical resize -3 -noremap :resize +3 -noremap :resize -3 - -" System clipboard interactions -map "+y -vnoremap "+p - -" Use more common Undo/Redo shortcuts -nnoremap :undo -nnoremap :redo - -" Use more common save shortcut -nnoremap :w - -" Terminal -nnoremap :vnew term://zshi -nnoremap :split term://zshi -nnoremap :tabnew term://zshi - -" Alias replace all -nnoremap :%s//gI - -" Start spell-check -map s :setlocal spell! spelllang=en_us - -" Use space for folding/unfolding sections -nnoremap za -vnoremap zf - -" Use shift to move 10 lines up/down quickly -noremap K 10k -noremap J 10j - -" Save file as sudo when no write permissions -cmap w!! w !sudo tee > /dev/null % - -" Stop search highlight with Esc in normal mode (until next search) -nnoremap :noh - -" Enable/Disable auto comment -map c :setlocal formatoptions-=cro -map C :setlocal formatoptions=cro - -" Don't leave visual mode after indenting -vmap < >gv - -" Compile opened file (using custom comp script) -nnoremap :w \| !comp % - -" Shell check -nnoremap p :!shellcheck % - -" Redefine the incredibely annoying mappings that trigger -" dynamic SQL completion with dbext and keeps on freezing -" vim whenever pressed with a message saying that -" dbext plugin isn't installed... -" See :h ft-sql.txt -let g:omni_sql_no_default_maps = 1 - diff --git a/home/.config/nvim/rc/plugins.d/airline.vim b/home/.config/nvim/rc/plugins.d/airline.vim deleted file mode 100644 index 47c7c88..0000000 --- a/home/.config/nvim/rc/plugins.d/airline.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Airline specific theming settings -let g:airline_theme='codedark' " Use codedark theme from vim-ariline-themes -let g:airline_right_sep = "" " Don't use special separators (<) -let g:airline_left_sep = "" " Don't use special separators (>) -let g:airline#extensions#tabline#enabled = 1 " Enable tabline (top line) -let g:airline#tabline#formatter = 'unique_tail' " Tabline filename formatter -let g:webdevicons_enable_airline_statusline = 0 " Use special icons from vim-devicons (requires nerdfonts) -let g:airline_powerline_fonts = 1 " Use special symbols from powerline fonts (line no, col no) - -if empty($DISPLAY) " Use ASCII-only if we're in TTY - let g:airline_symbols_ascii = 1 -endif - -" Disable airline in nerdtree buffer -"augroup filetype_nerdtree -" au! -" au FileType nerdtree call s:disable_airline_on_nerdtree() -" au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() -"augroup END -" -"fu s:disable_airline_on_nerdtree() abort -" let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 -" call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) -"endfu diff --git a/home/.config/nvim/rc/plugins.d/nerdtree.vim b/home/.config/nvim/rc/plugins.d/nerdtree.vim deleted file mode 100644 index 910a9c0..0000000 --- a/home/.config/nvim/rc/plugins.d/nerdtree.vim +++ /dev/null @@ -1,39 +0,0 @@ -" NERDTree config -map :NERDTreeToggle -let g:NERDTreeDirArrowExpandable = '►' -let g:NERDTreeDirArrowCollapsible = '▼' -let NERDTreeShowLineNumbers=1 -let NERDTreeShowHidden=1 -let NERDTreeMinimalUI = 1 -let g:NERDTreeWinSize=25 -if empty($DISPLAY) " Disable devicons for nerdtree in TTY - let g:webdevicons_enable_nerdtree = 0 -endif - -" If a directory is specified, start NERDTree and move the cursor to its window. -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | - \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | - \ endif - -" If a file is specified, start NERDTree and keep the cursor in file window. -"autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") | -" \ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif - -" Exit Vim if NERDTree is the only window left. -autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | - \ quit | endif - -" If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. -autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | - \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif - -" Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file -if ! empty($NERDTREE_BOOKMARKS) - if ! filereadable($NERDTREE_BOOKMARKS) - let dir = system('dirname $NERDTREE_BOOKMARKS') - let x = system('mkdir -p ' . dir) - let x = system('touch $NERDTREE_BOOKMARKS') - endif - let g:NERDTreeBookmarksFile = $NERDTREE_BOOKMARKS -endif diff --git a/home/.config/nvim/rc/plugins.d/vimwiki.vim b/home/.config/nvim/rc/plugins.d/vimwiki.vim deleted file mode 100644 index 2bc51a1..0000000 --- a/home/.config/nvim/rc/plugins.d/vimwiki.vim +++ /dev/null @@ -1,8 +0,0 @@ -let wiki_conf = {} -let wiki_conf.path = '~/Personal/vimwiki' -let wiki_conf.path_html = '~/Personal/vimwiki-html' -let wiki_conf.html_template = '~/Personal/vimwiki-html/template.tpl' -let wiki_conf.syntax = 'markdown' -let wiki_conf.ext = '.md' - -let g:vimwiki_list = [wiki_conf] diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim deleted file mode 100644 index fc1499f..0000000 --- a/home/.config/nvim/rc/plugins.vim +++ /dev/null @@ -1,42 +0,0 @@ -" This file handles plugin management with plug.vim -" It contains an automatic first-time installer for plug.vim and plugins -" It also sources plugin specific config files - -" Install plugins automatically -if ! filereadable(config_dir."/autoload/plug.vim") - echo "Downloading junegunn/vim-plug to manage plugins..." - let x = system('mkdir -p '.config_dir.'/autoload') - let x = system('curl https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim > '.config_dir.'/autoload/plug.vim') - autocmd VimEnter * PlugInstall -endif - -" Plug.vim plugin list -call plug#begin(config_dir."/plugged") - -" Code helpers -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'airblade/vim-gitgutter' -Plug 'dhruvasagar/vim-table-mode' -Plug 'preservim/nerdcommenter' -Plug 'tmhedberg/SimpylFold' -" Themes -Plug 'tomasiser/vim-code-dark' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'ryanoasis/vim-devicons' -Plug 'tiagofumo/vim-nerdtree-syntax-highlight' -" Misc -Plug 'vimwiki/vimwiki' -Plug 'wakatime/vim-wakatime' -Plug 'preservim/nerdtree' -Plug 'mhinz/vim-startify' - -call plug#end() - - -" Source more plugin-specific configuration files from here -let plugins_rc_dir = rc_dir."/plugins.d" -execute "source ".plugins_rc_dir."/airline.vim" -execute "source ".plugins_rc_dir."/nerdtree.vim" -execute "source ".plugins_rc_dir."/vimwiki.vim" -execute "source ".plugins_rc_dir."/coc.vim" diff --git a/home/.config/nvim/rc/theme.vim b/home/.config/nvim/rc/theme.vim deleted file mode 100644 index be6fcbf..0000000 --- a/home/.config/nvim/rc/theme.vim +++ /dev/null @@ -1,26 +0,0 @@ -" General colorscheme settings -syntax on " Turn syntax highlighting on -colorscheme codedark " Requires vim-code-dark plugin - -set cursorline " Highlight cursor line -set laststatus=2 " Always show status line -set number relativenumber " Show relative line numbers -set showmatch " Show matching brackets -set scrolloff=5 " Keep 5 lines horizonal scrolloff -set sidescrolloff=5 " Keep 5 characters vertical scrolloff - -set guioptions-=m " Remove menubar -set guioptions-=T " Remove toolbar -set guioptions-=r " Remove right-hand scrollbar -set guioptions-=L " Remove left-hand scrollbar - -" Use more noticable cursor line color -highlight CursorLine guibg=#2b2b2b - -" Don't use true colors in TTY -if empty($DISPLAY) - set notermguicolors -else - set termguicolors -endif -