all repos — dotfiles @ 305753e33f546d46cdbe2ff65458100410feafcd

my *nix dotfiles

nvim: More lua
Anirudh Oppiliappan x@icyphox.sh
Fri, 29 Jan 2021 10:42:22 +0530
commit

305753e33f546d46cdbe2ff65458100410feafcd

parent

7e6b617b4f7b7747d1e146ae25ddc25eebfdf253

M config/nvim/init.luaconfig/nvim/init.lua

@@ -16,3 +16,4 @@ paq 'editorconfig/editorconfig-vim'

paq 'zah/nim.vim' require('settings') +require('maps')
A config/nvim/lua/maps.lua

@@ -0,0 +1,27 @@

+local cmd = vim.cmd +local map = vim.api.nvim_set_keymap + +-- map the leader key +map('n', '<Space>', '', {}) +vim.g.mapleader = ' ' + + +options = { noremap = true } +map('n', '<leader><esc>', ':nohlsearch<cr>', options) +map('n', '<leader>n', ':bnext<cr>', options) +map('n', '<leader>p', ':bprev<cr>', options) + +-- Not an editor command: Wqa +cmd(':command! WQ wq') +cmd(':command! WQ wq') +cmd(':command! Wq wq') +cmd(':command! Wqa wqa') +cmd(':command! W w') +cmd(':command! Q q') + +-- check if fzy is loaded and in PATH +if vim.fn.executable('fzy') then + map('', '<leader>e', ':call FzyCommand("find . -type f ! -path \'*.git/*\'", ":e")<cr>', { noremap=true, silent=true }) +else + print('fzy not in PATH!') +end
A config/nvim/lua/settings.lua

@@ -0,0 +1,80 @@

+u = require('utils') + +local o = vim.o +local wo = vim.wo +local bo = vim.bo +local g = vim.g +local cmd = vim.cmd + +-- global options +o.swapfile = true +o.dir = '/tmp' +o.smartcase = true +o.laststatus = 2 +o.hlsearch = true +o.incsearch = true +o.ignorecase = true +o.scrolloff = 12 +o.timeoutlen = 3000 +o.ttimeoutlen = 100 +o.undodir = '~/.cache/nvim/undodir' +o.cursorline = false +o.foldenable = false +o.conceallevel = 2 +o.mouse = 'a' +o.wildmenu = true +o.tabstop = 4 +o.shiftwidth = 4 +o.softtabstop = 4 +o.showmode = false +o.clipboard = 'unnamedplus' +o.hidden = true +o.wildignore = [[ +.git,.hg,.svn +*.aux,*.out,*.toc +*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class +*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp +*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg +*.mp3,*.oga,*.ogg,*.wav,*.flac +*.eot,*.otf,*.ttf,*.woff +*.doc,*.pdf,*.cbr,*.cbz +*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb +*.swp,.lock,.DS_Store,._* +]] + +-- i couldn't figure out how to set the colorscheme in lua +vim.cmd('syntax on') +vim.cmd('colorscheme plain') +o.background = 'dark' + +-- gitgutter options +g.gitgutter_override_sign_column_highlight = 0 +g.gitgutter_sign_added = '+' +g.gitgutter_sign_modified = '±' +g.gitgutter_sign_removed = '-' +g.gitgutter_sign_removed_first_line = '^' +g.gitgutter_sign_modified_removed = '#' + +-- window-local options +wo.number = false +wo.wrap = false + +-- buffer-local options +bo.expandtab = true + +-- augroups don't have an interface yet +u.create_augroup({ + { 'BufRead,BufNewFile', '/tmp/nail-*', 'setlocal', 'ft=mail' }, + { 'BufRead,BufNewFile', '*s-nail-*', 'setlocal', 'ft=mail' }, +}, 'ftmail') + + +u.create_augroup({ + { 'BufReadPost', '*', [[ + if line("'\"") > 1 && line("'\"") <= line("$") + execute "normal! g`\"" + endif + ]] } +}, 'restorecursor') + +cmd('au BufNewFile,BufRead * if &ft == "" | set ft=text | endif')
A config/nvim/lua/utils.lua

@@ -0,0 +1,13 @@

+local M = {} +local cmd = vim.cmd + +function M.create_augroup(autocmds, name) + cmd('augroup ' .. name) + cmd('autocmd!') + for _, autocmd in ipairs(autocmds) do + cmd('autocmd ' .. table.concat(autocmd, ' ')) + end + cmd('augroup END') +end + +return M
M config/nvim/plugin/fzy.vimconfig/nvim/plugin/fzy.vim

@@ -1,5 +1,3 @@

-let g:fzy_loaded=0 - function! s:completed(winid, filename, action, ...) abort bdelete! call win_gotoid(a:winid)

@@ -25,6 +23,3 @@ call term_start(cmd, {'exit_cb': F, 'curwin': 1})

endif startinsert endfunction - -let g:fzy_loaded=1 -
D config/nvim/plugin/maps.vim

@@ -1,23 +0,0 @@

-" keybindings -let mapleader=' ' -nnoremap <leader><esc> :nohlsearch<cr> -nnoremap <leader>o :only<cr> -nnoremap H H:exec 'norm! '. &scrolloff . 'k'<cr> -nnoremap L L:exec 'norm! '. &scrolloff . 'j'<cr> -nnoremap <C-t> :tabedit -nnoremap <leader>n :bnext<cr> -nnoremap <leader>p :bprev<cr> - -" Not an editor command: Wqa -:command! WQ wq -:command! Wq wq -:command! Wqa wqa -:command! W w -:command! Q q - -" check if fzy is loaded and in PATH -if executable('fzy') && fzy_loaded - nnoremap <leader>e :call FzyCommand("find . -type f", ":e")<cr> - nnoremap <leader>v :call FzyCommand("find . -type f", ":vs")<cr> - nnoremap <leader>s :call FzyCommand("find . -type f", ":sp")<cr> -endif