From 1e27d1c7b25e4d28a25c0fa2c4e6e33a66b9072e Mon Sep 17 00:00:00 2001 From: moxie Date: Tue, 30 Sep 2025 12:27:44 +0300 Subject: add nvim configs --- .config/nvim/lua/config/options.lua | 160 ++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 .config/nvim/lua/config/options.lua (limited to '.config/nvim/lua/config/options.lua') diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..a362fcd --- /dev/null +++ b/.config/nvim/lua/config/options.lua @@ -0,0 +1,160 @@ +local opt = vim.opt + +-- vim.api.nvim_set_hl(0, "ColorColumn", { ctermbg = "NONE", bg = "NONE" }) + +-- colorscheme gruvbox +opt.termguicolors = true +opt.background = "dark" +vim.cmd.colorscheme("gruvbox") + +opt.mouse = "" -- disable mouse +opt.encoding = "utf-8" +opt.shortmess = "atI" -- disable intro screen +opt.inccommand = "nosplit" -- shows ex-command change previews +-- opt.inccommand = "split" +opt.smartcase = true +opt.ignorecase = true +opt.number = true +opt.relativenumber = true +opt.splitbelow = true +opt.splitright = true +opt.signcolumn = "yes" +opt.shada = { "'10", "<0", "s10", "h" } +opt.clipboard = "unnamedplus" +opt.expandtab = true -- expand tabs to spaces +opt.smarttab = false -- fuck tabs +-- opt.formatoptions:remove "o" -- Don't have `o` add a comment, should be in filetype (ftplugin) +opt.spell = false +opt.undolevels = 150 +opt.lazyredraw = true -- don't redraw screen during macros +opt.sc = true -- show incomplete command at bottom right +opt.swapfile = false +opt.backupdir = "/tmp" +opt.backupcopy = "yes" +opt.directory = "/tmp" + +opt.timeoutlen = 500 +opt.ttimeoutlen = 10 -- fix esc in tmux +opt.showmatch = true +opt.mat = 5 + +opt.visualbell = true +opt.foldenable = false +opt.foldmethod = "syntax" +opt.foldlevel = 1 +opt.foldnestmax = 10 +opt.tabstop = 8 -- n-space tab width +opt.shiftwidth = 2 -- allows the use of < and > for VISUAL indenting +opt.softtabstop = 2 -- counts n space when DELETE or BACKSPACE is used +opt.textwidth = 78 +opt.autoindent = true +opt.smartindent = true +opt.hlsearch = false +opt.incsearch = true +opt.backspace = "indent,eol,start" + +opt.history = 1000 -- 1000 lines of command history +opt.cmdheight = 1 -- command line height +opt.ruler = true -- ruler display in statusline +opt.showmode = true -- show mode at bottom of screen +opt.backup = false -- don't keep backups after close +opt.writebackup = true -- do keep one while working +opt.backupdir = "/tmp" +opt.backupcopy = "yes" +opt.directory = "/tmp" +opt.showmatch = true -- show matching brackets (), {}, [] +opt.whichwrap = "h,l,<,>,[,]" +opt.showcmd = true +opt.modeline = true +opt.formatoptions = "tcqjl" +opt.selection = "inclusive" +opt.autowrite = true +opt.cinoptions = "g0,:0,l1,(0,t0" +opt.shortmess = "at" +opt.complete = ".,t,i,b,w,k" +opt.wildchar = ("\t"):byte() +opt.wildmenu = true +opt.wildmode = "longest:full,full" +opt.wildignore = "*/.git/*,*/tmp/*,*.swp,*/node_modules/*" +opt.previewheight = 5 +opt.joinspaces = true +opt.magic = true +opt.suffixes = ".bak,~,.o,.info,.log,.rbx,.swp" +opt.title = true +opt.scrolloff = 8 -- start scrolling at 8 lines away from margins +opt.sidescrolloff = 15 +opt.sidescroll = 1 +opt.cursorline = true +opt.omnifunc = "syntaxcomplete#Complete" +opt.laststatus = 3 -- 2 +opt.completeopt = "menu,menuone,noselect" + +-- TODO: convert to lua or get lualine plugin +-- vim.cmd [[ +-- set statusline= +-- set statusline+=%#PmenuSel# +-- set statusline+=%#LineNr# +-- set statusline+=\ %F +-- set statusline+=%m +-- set statusline+=%= +-- set statusline+=%#CursorColumn# +-- set statusline+=\ %y +-- set statusline+=\ %{&fileencoding?&fileencoding:&encoding} +-- set statusline+=\ %{&fileformat} +-- set statusline+=\ %p%% +-- set statusline+=\ %l:%c +-- set statusline+=\ +-- ]] + +vim.cmd([[ + augroup encrypted + au! + autocmd BufReadPre,FileReadPre *.gpg set viminfo= + autocmd BufReadPre,FileReadPre *.gpg set noswapfile noundofile nobackup + autocmd BufReadPre,FileReadPre *.gpg set bin + autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 + autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null + autocmd BufReadPost,FileReadPost *.gpg set nobin + autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save + autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") + autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null + autocmd BufWritePost,FileWritePost *.gpg u + augroup END +]]) + +-- TODO: move and convert to lua +-- vimwiki (move to vimwiki.lua config) +--local hostname = vim.fn.hostname() +--if hostname == "arcana" then +-- vim.g.vimwiki_list = { { path = "/home/moxie/wiki" } } +--elseif hostname == "hideaway" then +-- vim.g.vimwiki_list = { { path = "/stash/wiki" } } +--end + +-- open vimwiki links in a new vim buffer instead of xdg-open +-- vim.cmd([[ +-- fun! VimwikiLinkHandler(link) +-- let link_infos = vimwiki#base#resolve_link(a:link) +-- try +-- if link_infos.filename =~ "^http" +-- exe '!$BROWSER "' . fnameescape(link_infos.filename) . '"' +-- else +-- exe "e " . fnameescape(link_infos.filename) +-- endif +-- return 1 +-- catch +-- echo "Failed opening " . a:link +-- return 0 +-- endtry +-- endfun +-- ]]) + +-- remove docx and xlsx from zip.vim +vim.g.zipPlugin_ext = +"*.zip,*.jar,*.xpi,*.ja,*.war,*.ear,*.celzip,*.oxt,*.kmz,*.wsz,*.xap,*.docm,*.dotx,*.dotm,*.potx,*.potm,*.ppsx,*.ppsm,*.pptx,*.pptm,*.ppam,*.sldx,*.thmx,*.xlam,*.xlsm,*.xlsb,*.xltx,*.xltm,*.xlam,*.crtx,*.vdw,*.glox,*.gcsx,*.gqsx" + +vim.cmd([[ + highlight GitGutterAdd guifg=#009900 ctermfg=2 + highlight GitGutterChange guifg=#bbbb00 ctermfg=3 + highlight GitGutterDelete guifg=#ff2222 ctermfg=1 +]]) -- cgit v1.2.3