From 7657a100d1f0644474103b536a22e3aa302824a4 Mon Sep 17 00:00:00 2001 From: Blista Kanjo Date: Thu, 22 Jun 2023 00:44:18 -0400 Subject: refactor: convert init.vim to init.lua --- .config/nvim/init.lua | 138 ++++++++++++++++++++++++++++++++++++++++++++ .config/nvim/init.vim | 156 -------------------------------------------------- 2 files changed, 138 insertions(+), 156 deletions(-) create mode 100644 .config/nvim/init.lua delete mode 100644 .config/nvim/init.vim diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..b34c5e2 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,138 @@ +-- init.lua + +-- Use System Clipboard +vim.opt.clipboard = "unnamedplus" + +-- Basic run commands +vim.cmd("colorscheme tender") +vim.cmd("filetype plugin on") +vim.cmd("syntax on") +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.cursorline = true +vim.cmd("highlight Cursorline cterm=bold ctermbg=black") +vim.cmd("filetype indent on") +vim.opt.mouse = "a" +vim.opt.hlsearch = true +vim.opt.autochdir = true + +-- Enable smartcase search sensitivity +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Indentation using spaces +-- tabstop: width of tab character +-- softtabstop: fine tunes the amount of whitespace to be added +-- shiftwidth: determines the amount of whitespace to add in normal mode +-- expandtab: when on use space instead of tab +-- textwidth: text wrap width +-- autoindent: autoindent in new line +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +-- vim.opt.textwidth = 79 +vim.opt.expandtab = true +vim.opt.autoindent = true + +-- Show the matching part of pairs [] {} and () +vim.opt.showmatch = true + +-- Remove trailing whitespace from Python and Fortran files +vim.api.nvim_exec([[ + autocmd BufWritePre *.py :%s/\s\+$//e + autocmd BufWritePre *.f90 :%s/\s\+$//e + autocmd BufWritePre *.f95 :%s/\s\+$//e + autocmd BufWritePre *.for :%s/\s\+$//e +]], false) + +if vim.fn.has('gui_running') == 1 then + vim.opt.t_Co = 256 + vim.opt.guifont = "JetBrains Mono 11" + vim.opt.guioptions:remove("m") + vim.opt.guioptions:remove("T") + vim.opt.guioptions:remove("r") + vim.opt.guioptions:remove("L") + vim.cmd("colorscheme tender") +end + +-- Enable true colors support +vim.opt.termguicolors = true + +if vim.env.TERM == "alacritty" then + vim.opt.ttymouse = "sgr" +end + +-- Keybinds for x clipboard +vim.api.nvim_set_keymap("v", "", '"+y', {}) +vim.api.nvim_set_keymap("v", "", '"+x', {}) +vim.api.nvim_set_keymap("n", "", '"+p', {}) +vim.api.nvim_set_keymap("n", "p", '"+P', {}) + +-- Vertical Motions Mappings +vim.api.nvim_set_keymap("n", "", "zz", { noremap = true }) +vim.api.nvim_set_keymap("n", "", "zz", { noremap = true }) +vim.api.nvim_set_keymap("n", "n", "nzzzv", { noremap = true }) +vim.api.nvim_set_keymap("n", "N", "Nzzzv", { noremap = true }) + +-- NERDTree Keybinds +vim.api.nvim_set_keymap("n", "n", ":NERDTreeFocus", { noremap = true }) +vim.api.nvim_set_keymap("n", "", ":NERDTree", { noremap = true }) +vim.api.nvim_set_keymap("n", "", ":NERDTreeToggle", { noremap = true }) +vim.api.nvim_set_keymap("n", "", ":NERDTreeFind", { noremap = true }) + +-- Plugin manager (vim-plug) +vim.cmd [[ + call plug#begin('~/.vim/plugged') + Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } + " Plug 'LunarWatcher/auto-pairs' + Plug 'tmsvg/pear-tree' + Plug 'adelarsq/vim-matchit' + Plug 'neoclide/coc.nvim', { 'branch': 'release' } + Plug 'tpope/vim-surround' + Plug 'junegunn/fzf' + call plug#end() +]] + +-- Use a line cursor within insert mode and a block cursor everywhere else. +-- Reference chart of values: +-- Ps = 0 -> blinking block. +-- Ps = 1 -> blinking block (default). +-- Ps = 2 -> steady block. +-- Ps = 3 -> blinking underline. +-- Ps = 4 -> steady underline. +-- Ps = 5 -> blinking bar (xterm). +-- Ps = 6 -> steady bar (xterm). +vim.g.t_SI = "\27[6 q" +vim.g.t_EI = "\27[2 q" + +-- Fix the cursor change timeout between insert and normal mode (see function above) +vim.opt.ttimeout = true +vim.opt.ttimeoutlen = 1 +vim.opt.listchars = { tab = ">-", trail = "~", extends = ">", precedes = "<", space = "." } +vim.opt.ttyfast = true + +-- Tab Autocompletion for COC.NVIM +local function check_back_space() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil +end + +vim.api.nvim_set_keymap("i", "", "pumvisible() ? '' : v:lua.check_back_space() ? '' : 'refresh()'", { expr = true, noremap = true }) +vim.api.nvim_set_keymap("i", "", "pumvisible() ? '' : ''", { expr = true, noremap = true }) + +-- COC.NVIM colors +vim.cmd("highlight CocFloating ctermbg=0") +vim.cmd("highlight CocErrorFloat ctermfg=15") + +-- Customize split dividers +vim.opt.fillchars = vim.opt.fillchars + { + vert = "█", + fold = "█", + diff = "█", + stl = "=", + stlnc = "=", + stl = "=" +} +vim.cmd("highlight VertSplit ctermfg=235 guifg=#3c3836") +vim.cmd("highlight StatusLine ctermfg=black ctermbg=lightgray") +vim.cmd("highlight StatusLineNC ctermfg=darkgray ctermbg=lightgray") diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim deleted file mode 100644 index 1ce5f96..0000000 --- a/.config/nvim/init.vim +++ /dev/null @@ -1,156 +0,0 @@ -" ▄▄ ▄▄ ▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄ -" █ █ █ █ █ █▄█ █ ▄ █ █ █ -" █ █▄█ █ █ █ █ █ █ █ █ -" █ █ █ █ █▄▄█▄█ ▄▄█ -" ▄▄▄ █ █ █ █ ▄▄ █ █ -" █ █ █ ██ █ ██▄██ █ █ █ █ █▄▄ -" █▄▄▄█ █▄▄▄█ █▄▄▄█▄█ █▄█▄▄▄█ █▄█▄▄▄▄▄▄▄█ - -" Use System Clipboard -":set clipboard=unnamedplus - -" ┌┐ ┌─┐┌─┐┬┌─┐ ┬─┐┬ ┬┌┐┌ ┌─┐┌─┐┌┬┐┌┬┐┌─┐┌┐┌┌┬┐┌─┐ -" ├┴┐├─┤└─┐││ ├┬┘│ ││││ │ │ │││││││├─┤│││ ││└─┐ -" └─┘┴ ┴└─┘┴└─┘ ┴└─└─┘┘└┘ └─┘└─┘┴ ┴┴ ┴┴ ┴┘└┘─┴┘└─┘ -colorscheme tender -filetype plugin on -syntax on -set number -set relativenumber -set cursorline -:highlight Cursorline cterm=bold ctermbg=black -filetype indent on -set mouse=a -set hlsearch -set autochdir - -" enable smartcase search sensitivity " -set ignorecase -set smartcase - -" Indentation using spaces " -" tabstop: width of tab character -" softtabstop: fine tunes the amount of whitespace to be added -" shiftwidth: determines the amount of whitespace to add in normal mode -" expandtab: when on use space instead of tab -" textwidth: text wrap width -" autoindent: autoindent in new line -set tabstop =4 -set softtabstop =4 -set shiftwidth =4 -" set textwidth =79 -set expandtab -set autoindent - -" show the matching part of pairs [] {} and () " -set showmatch - -" remove trailing whitespace from Python and Fortran files " -autocmd BufWritePre *.py :%s/\s\+$//e -autocmd BufWritePre *.f90 :%s/\s\+$//e -autocmd BufWritePre *.f95 :%s/\s\+$//e -autocmd BufWritePre *.for :%s/\s\+$//e - -if has('gui_running') - set t_Co=256 - set guifont=JetBrains\ Mono\ 11 - set guioptions-=m - set guioptions-=T - set guioptions-=r - set guioptions-=L - colorscheme evening -endif - -" enable true colors support " -set termguicolors - -if $TERM == 'alacritty' - set ttymouse=sgr -endif - -" ╦╔═┌─┐┬ ┬┌┐ ┬┌┐┌┌┬┐┌─┐ ┌─┐┌─┐┬─┐ ═╗ ╦ ╔═╗┬ ┬┌─┐┌┐ ┌─┐┌─┐┬─┐┌┬┐ -" ╠╩╗├┤ └┬┘├┴┐││││ ││└─┐ ├┤ │ │├┬┘ ╔╩╦╝ ║ │ │├─┘├┴┐│ │├─┤├┬┘ ││ -" ╩ ╩└─┘ ┴ └─┘┴┘└┘─┴┘└─┘ └ └─┘┴└─ ╩ ╚═ ╚═╝┴─┘┴┴ └─┘└─┘┴ ┴┴└──┴┘ - -vnoremap "+y -vmap "+x -map "+p -map p "+P - -" Vertical Motions Mappings -nnoremap zz -nnoremap zz -nnoremap n nzzzv -nnoremap N Nzzzv - -" NERDTree Keybinds -nnoremap n :NERDTreeFocus -nnoremap :NERDTree -nnoremap :NERDTreeToggle -nnoremap :NERDTreeFind - -" ╔═╗┬ ┬ ┬┌─┐┬┌┐┌ ╔╦╗┌─┐┌┐┌┌─┐┌─┐┌─┐┬─┐ -" ╠═╝│ │ ││ ┬││││ ║║║├─┤│││├─┤│ ┬├┤ ├┬┘ -" ╩ ┴─┘└─┘└─┘┴┘└┘ ╩ ╩┴ ┴┘└┘┴ ┴└─┘└─┘┴└─ - -call plug#begin() -Plug 'https://github.com/preservim/nerdtree', { 'on': 'NERDTreeToggle' } -" Plug 'LunarWatcher/auto-pairs' -Plug 'tmsvg/pear-tree' -Plug 'https://github.com/adelarsq/vim-matchit' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'tpope/vim-surround' -Plug 'sbdchd/neoformat' -Plug 'ThePrimeagen/vim-be-good' -Plug 'junegunn/fzf' -call plug#end() - -" Use a line cursor within insert mode and a block cursor everywhere else. -" -" Reference chart of values: -" Ps = 0 -> blinking block. -" Ps = 1 -> blinking block (default). -" Ps = 2 -> steady block. -" Ps = 3 -> blinking underline. -" Ps = 4 -> steady underline. -" Ps = 5 -> blinking bar (xterm). -" Ps = 6 -> steady bar (xterm). -let &t_SI = "\e[6 q" -let &t_EI = "\e[2 q" - -" Fix the cursor change timeout between insert and normal mode (see function -" above) -" -" -set ttimeout -set ttimeoutlen=1 -set listchars=tab:>-,trail:~,extends:>,precedes:<,space:. -set ttyfast - -" Tab Autocompletion for COC NVIM -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -inoremap - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\" : - \ coc#refresh() -inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - -" COC.NVIM colors -highlight CocFloating ctermbg=0 -highlight CocErrorFloat ctermfg=15 - -" Customize split dividers -set fillchars+=vert:\█ -set fillchars+=fold:\█ -set fillchars+=diff:\█ -set fillchars+=msgsep:\█ -set fillchars+=stl:\= -set fillchars+=stlnc:\= -set fillchars+=stl:\= -highlight VertSplit ctermfg=235 guifg=#3c3836 -highlight StatusLine ctermfg=black ctermbg=lightgray -highlight StatusLineNC ctermfg=darkgray ctermbg=lightgray -- cgit v1.2.3