dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

init.lua (7456B)


      1 --                                     ██
      2 --                                    ░░
      3 --  ███████   █████   ██████  ██    ██ ██ ██████████
      4 -- ░░██░░░██ ██░░░██ ██░░░░██░██   ░██░██░░██░░██░░██
      5 --  ░██  ░██░███████░██   ░██░░██ ░██ ░██ ░██ ░██ ░██
      6 --  ░██  ░██░██░░░░ ░██   ░██ ░░████  ░██ ░██ ░██ ░██
      7 --  ███  ░██░░██████░░██████   ░░██   ░██ ███ ░██ ░██
      8 -- ░░░   ░░  ░░░░░░  ░░░░░░     ░░    ░░ ░░░  ░░  ░░
      9 --
     10 --  author ▓▒ pyratebeard <root@pyratebeard.net>
     11 --    code ▓▒ https://git.pyratebeard.net/dotfiles
     12 
     13 -- ▓▓▒░ general
     14 -- security
     15 vim.opt.modelines = 0
     16 
     17 -- https://neovim.discourse.group/t/how-do-i-prevent-neovim-commenting-out-next-line-after-a-comment-line/3711/4
     18 vim.opt.paste = true
     19 
     20 -- set leader
     21 vim.g.mapleader = ","
     22 
     23 -- hide buffers
     24 vim.opt.hidden = true
     25 
     26 -- maintain undo history between sessions
     27 vim.opt.undofile = true
     28 vim.opt.undodir = vim.fn.stdpath("data") .. "/undo"
     29 vim.opt.swapfile = false
     30 
     31 -- fuzzy find
     32 vim.opt.path:append("**")
     33 
     34 -- lazy file name tab completion
     35 vim.opt.wildmode = "list:longest,list:full"
     36 vim.opt.wildmenu = true
     37 vim.opt.wildignorecase = true
     38 
     39 -- ignore files vim doesnt use
     40 vim.opt.wildignore:append(".git,.hg,.svn")
     41 vim.opt.wildignore:append(".aux,*.out,*.toc")
     42 vim.opt.wildignore:append(".o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class")
     43 vim.opt.wildignore:append(".ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp")
     44 vim.opt.wildignore:append(".avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg")
     45 vim.opt.wildignore:append(".mp3,*.oga,*.ogg,*.wav,*.flac")
     46 vim.opt.wildignore:append(".eot,*.otf,*.ttf,*.woff")
     47 vim.opt.wildignore:append(".doc,*.pdf,*.cbr,*.cbz")
     48 vim.opt.wildignore:append(".zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb")
     49 vim.opt.wildignore:append(".swp,.lock,.DS_Store,._*")
     50 vim.opt.wildignore:append(".,..")
     51 
     52 -- case insensitive search
     53 vim.opt.ignorecase = true
     54 vim.opt.smartcase = true
     55 vim.opt.infercase = true
     56 
     57 -- make backspace behave in a sane manner
     58 vim.opt.backspace = "indent,eol,start"
     59 
     60 -- searching
     61 vim.opt.hlsearch = true
     62 vim.opt.incsearch = true
     63 vim.opt.inccommand = "split"
     64 
     65 -- use indents of 2
     66 vim.opt.shiftwidth = 2
     67 
     68 -- tabs are tabs
     69 vim.opt.expandtab = false
     70 
     71 -- an indentation every 2 columns
     72 vim.opt.tabstop = 2
     73 
     74 -- let backspace delete indent
     75 vim.opt.softtabstop = 2
     76 
     77 -- enable auto indentation
     78 vim.opt.autoindent = true
     79 
     80 -- disable pesky mouse
     81 vim.opt.mouse = ""
     82 
     83 -- ▓▓▒░ ui
     84 -- show matching brackets/parenthesis
     85 vim.opt.showmatch = true
     86 
     87 -- disable startup message
     88 vim.opt.shortmess:append("sI")
     89 
     90 -- syntax highlighting
     91 vim.opt.termguicolors = true
     92 vim.opt.synmaxcol = 512
     93 
     94 -- show line numbers
     95 vim.opt.number = true
     96 
     97 -- no line wrapping
     98 vim.opt.wrap = false
     99 vim.opt.linebreak = true
    100 
    101 -- set indents when wrapped
    102 vim.opt.breakindent = true
    103 
    104 -- highlight line
    105 vim.opt.cursorline = true
    106 
    107 -- cursor always block
    108 vim.opt.guicursor = "n-v-i-c:block-Cursor"
    109 
    110 -- show invisibles
    111 vim.opt.listchars = { tab = "  ", trail = "·", extends = "»", precedes = "«", nbsp = "░" }
    112 vim.opt.list = true
    113 
    114 -- split directions
    115 vim.opt.fillchars = { vert = "▒" }
    116 vim.opt.splitright = true
    117 vim.opt.splitbelow = true
    118 
    119 --
    120 --" stop unnecessary rendering
    121 --set lazyredraw
    122 --
    123 --" no folding
    124 --set foldlevel=99
    125 --set foldminlines=99
    126 --
    127 
    128 --" MACROS
    129 --" target blank links
    130 --" used in blog md files
    131 --let @t='{target="_blank" rel="noreferrer"}'
    132 
    133 -- ▓▓▒░ commands
    134 local f = require("utils.functions")
    135 local r = require("utils.remaps")
    136 
    137 -- remove highlighting
    138 r.noremap("n", "<esc><esc>", ":nohlsearch<cr>", "remove highlighting", { silent = true })
    139 
    140 -- vertical term
    141 -- TODO auto append when term opens
    142 r.noremap("n", "<leader>z", ":cd %:h | :vs | :set nu! | :term<cr>", "vertical terminal", { silent = true })
    143 r.noremap("n", "<leader>Z", ":cd %:h | :split | :set nu! | :term<cr>", "terminal", { silent = true })
    144 
    145 -- remove trailing white space
    146 f.cmd("Nows", "%s/\\s\\+$//e", { desc = "remove trailing whitespace" })
    147 
    148 -- remove blank lines
    149 f.cmd("Nobl", "g/^\\s*$/d", { desc = "remove blank lines" })
    150 
    151 -- the worst place in the world
    152 r.noremap("n", "Q", "<nop>", "")
    153 
    154 -- wrap and spellcheck when writing
    155 -- nnoremap <C-w>w :set wrap<CR>:Spell<CR>
    156 f.cmd("Sp", "setlocal spell! spell?", { desc = "toggle spell check" })
    157 r.noremap("n", "<leader>s", ":Sp<cr>", "toggle spell check")
    158 r.noremap("n", "<leader>sw", ":set wrap<cr>:Sp<cr>", "wrap and toggle spell check")
    159 
    160 -- make current buffer executable
    161 f.cmd("Chmodx", "!chmod a+x %", { desc = "make current buffer executable" })
    162 r.noremap("n", "<leader>x", ":Chmodx<cr>", "chmod +x buffer")
    163 
    164 -- 
    165 -- vnoremap <silent> <leader>y :w !xsel -i -b<CR>
    166 -- nnoremap <silent> <leader>y V:w !xsel -i -b<CR>
    167 -- nnoremap <silent> <leader>p :silent :r !xsel -o -b<CR>
    168 -- 
    169 -- " switch tabs
    170 -- nnoremap <C-n> :tabn<CR>
    171 -- nnoremap <C-p> :tabp<CR>
    172 -- 
    173 -- " nerdtree
    174 -- nnoremap <C-j> :NERDTreeToggle<CR>
    175 -- 
    176 -- " toggle autoindent
    177 -- nnoremap <F8> :setl noai<CR>
    178 -- nnoremap <F9> :setl ai<CR>
    179 -- 
    180 -- " goyo
    181 -- nnoremap <C-w>g :Goyo<CR>
    182 -- 
    183 -- " start webserver
    184 -- "nnoremap <leader>h :!busybox httpd -f -h . -p 8080
    185 -- 
    186 -- " list buffers and wait for number
    187 -- nnoremap <leader>b :ls<CR>:b
    188 -- 
    189 -- " fzf
    190 -- "nnoremap <leader>f :cd $HOME/src <bar>FZF<CR>
    191 -- nnoremap <leader>f :cd %:p:h <bar>FZF<CR>
    192 -- 
    193 -- " list registers
    194 -- nnoremap <leader>r :registers<CR>
    195 -- 
    196 -- " swap ' and ` for marks
    197 -- nnoremap ' `
    198 -- nnoremap ` '
    199 -- " columns
    200 -- " 80 soft 120 hard
    201 -- let &colorcolumn="80"
    202 -- 
    203 -- " COMMANDS
    204 -- " json pretty print
    205 -- command J :%!python -mjson.tool
    206 -- 
    207 -- " git commit shortcut
    208 -- command Ga Git add %
    209 -- command Gc Git commit -S
    210 -- command Gac Git commit -a -S -m "updates"
    211 -- command Gf Git fetch
    212 -- command Gp Git push
    213 -- command -nargs=* Gco Git checkout
    214 -- command Gm Git merge
    215 
    216 -- ▓▓▒░ plugins
    217 -- TODO lightline
    218 local pluginspath = vim.fn.stdpath("data") .. "/lazy"
    219 local lazypath = pluginspath .. "/lazy.nvim"
    220 
    221 -- install lazy
    222 if not vim.loop.fs_stat(lazypath) then
    223 	vim.fn.system({
    224 		"git",
    225 		"clone",
    226 		"--filter=blob:none",
    227 		"--single-branch",
    228 		"https://github.com/folke/lazy.nvim.git",
    229 		lazypath,
    230 	})
    231 end
    232 vim.opt.runtimepath:prepend(lazypath)
    233 
    234 -- use a protected call so we don't error out on first use
    235 local status_ok, lazy = pcall(require, "lazy")
    236 if not status_ok then
    237 	print("lazy just installed, please restart neovim")
    238 	return
    239 end
    240 
    241 ---- install plugins
    242 lazy.setup({
    243 	spec = {
    244 		--require("plugins.alpha"),
    245 		require("plugins.fzf"),
    246 		require("plugins.git"),
    247 		require("plugins.gitsigns"),
    248 		require("plugins.indent"),
    249 		require("plugins.lush"),
    250 		require("plugins.oldriceputin"),
    251 		require("plugins.telescope"),
    252 		require("plugins.vimwiki"),
    253 	},
    254 	dev = {
    255 		path = "~/.local/src/warez",
    256 	},
    257 	lockfile = vim.fn.stdpath("config") .. "/lua/plugins/lazy-lock.json",
    258 	ui = {
    259 		size = { width = 0.8, height = 0.8 },
    260 		wrap = true,
    261 		border = "shadow",
    262 		icons = require("utils.icons").lazy,
    263 	},
    264 	performance = {
    265 		cache = {
    266 			enabled = true,
    267 		},
    268 		reset_packpath = true,
    269 		rtp = {
    270 			disabled_plugins = {
    271 				"netrwPlugin",
    272 			},
    273 		},
    274 	},
    275 })