changeset 423:5683e8e3e361

Use lua to configure
author zegervdv <zegervdv@me.com>
date Sun, 25 Jul 2021 18:16:46 +0200
parents 24330d37c9e3
children f42ea4c4a78c
files dot_config/nvim/init.lua dot_config/nvim/plugin/config.vim
diffstat 2 files changed, 155 insertions(+), 226 deletions(-) [+]
line wrap: on
line diff
--- a/dot_config/nvim/init.lua	Tue Jul 27 18:31:48 2021 +0200
+++ b/dot_config/nvim/init.lua	Sun Jul 25 18:16:46 2021 +0200
@@ -56,7 +56,20 @@
 
     -- Git/VCS
     use { 'vim-scripts/gitignore' }
-    use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } }
+    use {
+      'sjl/splice.vim',
+      opt = true,
+      cmd = { 'SpliceInit' },
+      config = function()
+        vim.g.splice_initial_diff_grid = 1
+        vim.g.splice_initial_diff_compare = 1
+        vim.g.splice_initial_diff_path = 0
+        vim.g.splice_initial_scrollbind_grid = 1
+        vim.g.splice_initial_scrollbind_compare = 1
+        vim.g.splice_initial_scrollbind_path = 1
+        vim.g.splice_wrap = 'nowrap'
+      end,
+    }
     use { 'tpope/vim-git' }
 
     -- Comments
@@ -67,7 +80,13 @@
 
     -- Parentheses etc
     use { 'tpope/vim-surround' }
-    use { 'raimondi/delimitMate' }
+    use {
+      'raimondi/delimitMate',
+      config = function()
+        vim.g.delimitMate_expand_cr = 1
+        vim.g.delimitMate_expand_space = 1
+      end,
+    }
 
     -- Moving around within lines
     use { 'wellle/targets.vim', event = 'InsertEnter *' }
@@ -361,6 +380,134 @@
   end)
 end, 0)
 
+-- Configuration
+local opt = vim.opt
+
+opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything
+
+opt.autoread = true -- Read changed files
+opt.hidden = true -- Allow to move away from modified files
+opt.autowriteall = true -- Write changes when losing focus
+
+-- Visuals
+opt.number = true
+opt.relativenumber = true
+opt.scrolloff = 4
+opt.showcmd = true -- Show incomplete commands while typing
+
+opt.termguicolors = true
+opt.background = 'dark'
+
+opt.showmatch = true -- Highligh matching braces
+
+opt.wrap = true -- Wrap lines
+opt.wrapmargin = 2 -- Stay 2 chars from side
+opt.textwidth = 79
+opt.colorcolumn = '81' -- Show indication of 81 chars
+opt.linebreak = true -- Smarter wrapping
+opt.breakindent = true -- Indent wrapped lines to same level
+
+opt.fixendofline = true -- Add EOL when missing
+
+opt.expandtab = true -- Add spaces when pressing tab
+opt.tabstop = 2 -- Tab is 2 spaces
+opt.shiftwidth = 2 -- Shift per 2 spaces
+opt.shiftround = true -- Round shifts to allign (1 space + tab = 2 spaces)
+
+-- Searching and substitute
+opt.magic = true -- Enable regexes
+opt.hlsearch = true -- Highlight all matches
+opt.incsearch = true -- Show matches while typing
+opt.ignorecase = true
+opt.smartcase = true -- When search pattern contains cases, be case sensitive
+opt.gdefault = true -- Use global flag for substitute: replace all matches on line
+opt.inccommand = 'nosplit' -- Show live replacements directly in text
+
+opt.autoindent = true
+opt.cindent = true -- C-syntax based indenting
+
+opt.updatetime = 300 -- Faster triggering of CursorHold events
+
+opt.errorbells = false -- Don't you beep to me
+
+opt.history = 1000 -- Remember last commands
+
+opt.wildmenu = true -- Command completion
+opt.wildmode = { longest = 'full', 'full' } -- Complete the fullest match
+opt.shortmess:append 'c' -- Hide ins-completion messages
+
+opt.ttyfast = true -- fast terminal
+opt.lazyredraw = true
+opt.ttimeoutlen = -1 -- Minimum timeout
+
+opt.diffopt:append 'iwhite' -- Ignore whitespace in diffs
+opt.diffopt:append 'internal' -- Internal diff engine
+opt.diffopt:append 'algorithm:patience' -- Use patience algorithm
+
+opt.tags = { '.git/tags', 'tags' }
+
+opt.path:append '**' -- Recursively search current directory
+
+opt.formatoptions = {
+  c = true, -- Wrap comments
+  r = true, -- Continue comments
+  o = true, -- Insert comment with o/O
+  q = true, -- Format comments with gq
+  n = true, -- Indent numbered lists
+  [2] = true, -- Indent from 2nd line of paragraph
+  [1] = true, -- Don't break before one letter words
+}
+
+opt.signcolumn = 'yes' -- Always show signcolumn
+
+opt.cursorline = true
+
+-- Show certain characters
+opt.list = true
+opt.listchars = { trail = '·', extends = '>', precedes = '<', nbsp = '+' }
+
+opt.sessionoptions:remove 'options' -- Remove options from saved sessions (reload from config)
+
+opt.completeopt = { 'menu', 'menuone', 'noselect' }
+
+opt.splitright = true -- Open new splits to right
+opt.virtualedit = 'block' -- Enable block editting
+
+opt.conceallevel = 0 -- Disable conceal
+
+opt.pastetoggle = '<F2>' -- Enable paste mode
+
+opt.undofile = true -- Persistently remember undos
+opt.undolevels = 1000
+opt.undodir = os.getenv 'HOME' .. '/.config/nvim/tmp/undo//'
+opt.swapfile = false -- Disable swap files
+opt.backup = true -- Keep backups
+opt.backupdir = os.getenv 'HOME' .. '/.config/nvim/tmp/backup//'
+
+-- Files to ignore from completion
+opt.wildignore:append {
+  '*/tmp/*',
+  '*.so',
+  '*.swp',
+  '*.zip',
+  '*.o',
+  '*.bin',
+  '*.elf',
+  '*.hex',
+  '*.eps',
+  '.git/*',
+  '*.dup',
+  '.hg/**',
+  '*.orig',
+  '*.*~',
+}
+
+opt.mouse = {
+  n = true, -- Normal mode
+  i = true, -- Insert mode
+  c = true, -- Commandline mode
+}
+
 -- LSP config
 local lsp = require 'lspconfig'
 local null_ls = require 'null-ls'
--- a/dot_config/nvim/plugin/config.vim	Tue Jul 27 18:31:48 2021 +0200
+++ b/dot_config/nvim/plugin/config.vim	Sun Jul 25 18:16:46 2021 +0200
@@ -25,164 +25,12 @@
 
 " General Settings and options {{{
 
-" Backspace over everything, like normal 
-set backspace=2
-
-" Buffers
-set autoread " Read external changes
-set hidden " Change between buffers without saving
-set autowriteall " Write changes when losing focus
-
-" Visuals
-set number
-set relativenumber
-set ruler
-syntax on
-set title
-set scrolloff=4 " Stay 4 lines from top/bottom
-set showcmd
-
-" Theme and style
-
-set termguicolors
-
-set background=dark
-
-if s:windows
-  set background=light
-  colorscheme PaperColor
-  set guifont=consolas:h10
-endif
-
-set showmatch " Highlight matching brackets
-
-set wrap " Wrap lines
-set wrapmargin=2 " Stay 2 chars from side
-set textwidth=79
-set colorcolumn=81
-set linebreak " Smarter wrapping
-if v:version > 703
-  set breakindent " Indent wrapped lines to same level
-endif
-
-set fixendofline
-
-set expandtab " Expand tabs to spaces
-set tabstop=2 shiftwidth=2 " Tab is 2 spaces
-
-set shiftround " Round shift indents to nearest value
-
-" Searching
-set magic  " Use magic regexes
-set hlsearch " Highlight all matches
-set incsearch " Show matches while typing
-set ignorecase " Ignore case when searching
-set smartcase " Be case sensitive if at least one uppercase char is used
-set gdefault " Default substitute all matches on a line
-if has('nvim')
-  set inccommand=nosplit
-endif
-
-set autoindent " Automatically indent
-set cindent " Indent based on C syntax
-set cinwords+=foreach
-
-set updatetime=300
-
-if s:darwin
-  set vb
-endif
-set noerrorbells " Don't beep
-
-set guioptions-=r
-set guioptions-=l
-set guioptions-=R
-set guioptions-=L
-set guioptions-=a
-set guioptions-=m
-set guioptions-=T
-set guioptions+=c
-
-set history=100 " Set history 100
-set wildmenu " Command completion
-set wildmode=longest:full,full " Complete to fullest match
-set ttyfast " Use a fast terminal
-set lazyredraw " No need to redraw constantly
-set shortmess+=c
-
-set ttimeoutlen=-1 " Set the timeout to a minimum
-set diffopt+=iwhite " Ignore spaces in diffs"
-set diffopt+=internal,algorithm:patience " use patience algorithm for better diffs
-
-set tags=.git/tags,tags,/project/asic_fpga/tools/vim/share/vim/vimfiles/tags
-
-" Have find look through all folders
-set path+=**
-" Add PRJROOT and subdirs to path if it is set
-if exists('$PRJROOT')
-  set path+=$PRJROOT/**
-endif
-
-set formatoptions=
-set formatoptions+=c " Format comments
-set formatoptions+=r " Continue comments by default
-set formatoptions+=o " Make comment when using o or O from comment line
-set formatoptions+=q " Format comments with gq
-set formatoptions+=n " Recognize numbered lists
-set formatoptions+=2 " Use indent from 2nd line of a paragraph
-" set formatoptions+=l " Don't break lines that are already long
-set formatoptions+=1 " Break before 1-letter words
-
-set signcolumn=yes
-
-" Enable cursorline
-set cursorline
 augroup cline
   au!
   autocmd WinEnter * setlocal cursorline
   autocmd WinLeave * setlocal nocursorline
 augroup END
 
-if !s:windows
-  set list
-  set listchars=tab:»\ ,trail:·,extends:>,precedes:<,nbsp:+
-endif
-
-set sessionoptions-=options
-
-" Scan files for completion
-set complete=.,w,b,u,k,kspell,t,i,d
-set completeopt=menu,menuone,noselect
-
-set splitright
-set virtualedit=block
-
-if v:version > 703
-  set conceallevel=0
-  if !has('nvim')
-    set cryptmethod=blowfish2
-  endif
-endif
-
-filetype plugin indent on
-
-set pastetoggle=<F2> " Toggle to paste mode
-
-if v:version >= 703
-  set undofile
-endif
-set undolevels=1000
-set backup
-set noswapfile
-if has('nvim')
-  " set viminfo+=n~/.config/nvim/.viminfo
-  set backupdir=~/.config/nvim/tmp/backup/,.
-  set directory=~/.config/nvim/tmp/swap//,.
-else
-  set viminfo+=n~/.vim/.viminfo
-  set backupdir=~/.vim/tmp/backup/,.
-  set directory=~/.vim/tmp/swap//,.
-endif
 if !isdirectory(expand(&backupdir))
   call mkdir(expand(&backupdir), "p")
 endif
@@ -191,22 +39,11 @@
 endif
 
 if v:version >= 703
-  if has('nvim')
-    set undodir=~/.config/nvim/tmp/undo//,.
-  else
-    set undodir=~/.vim/tmp/undo//,.
-  endif
   if !isdirectory(expand(&undodir))
     call mkdir(expand(&undodir), "p")
   endif
 endif
 
-
-set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex,*.eps,.git/**,*.dup,.hg/**,*.orig,*.*~
-
-" No selecting via mouse (stops visual selection when scrolling)
-set mouse=nic
-
 " }}}
 
 " Mappings {{{
@@ -347,9 +184,9 @@
 endif
 
 " Open buffers, tags... in vertical splits
-nnoremap <leader>b :vert sbuffer 
-nnoremap <leader>t :vert stjump 
-nnoremap <leader>f :vert sfind 
+nnoremap <leader>b :vert sbuffer
+nnoremap <leader>t :vert stjump
+nnoremap <leader>f :vert sfind
 
 
 " }}}
@@ -733,25 +570,6 @@
 " }}}
 
 " Filetype specific settings {{{
-" Latex {{{
-" Open pdf
-
-function! Latexprog()
-  if !filereadable("./Makefile")
-    setlocal makeprg=latexmk\ -interaction=nonstopmode\ -synctex=1\ -file-line-error\ -pdf\ %:r
-  endif
-endfunction
-
-augroup latex
-  autocmd!
-  autocmd FileType tex call Latexprog()
-  au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb
-  au BufNewFile,BufRead,BufEnter *.tex setlocal textwidth=0
-augroup END
-" }}}
-" Markdown {{{
-let g:vim_markdown_folding_disabled=1
-" }}}
 " Text {{{
 augroup ft_text
   au!
@@ -767,8 +585,8 @@
 
 function! ColorRpt()
   " Color numbers based on length
-  syn match String "\v<\d{1,3}>"   
-  syn match Number "\v<\d{4,6}>"   
+  syn match String "\v<\d{1,3}>"
+  syn match Number "\v<\d{4,6}>"
   syn match Statement "\v<\d{7,9}>"
 
   " Color errors
@@ -800,32 +618,6 @@
   au FileType c setlocal foldmethod=syntax
 augroup END
 " }}}
-" VHDL {{{
-" VHDL ctags
-let g:tlist_vhdl_settings = 'vhdl;d:package declarations;b:package bodies;e:entities;a:architecture specifications;t:type declarations;p:processes;f:functions;r:procedures'
-let g:vhdl_indent_genportmap =0
-let g:vhdl_indent_rhassign = 1
-
-augroup ft_vhdl
-  au!
-  autocmd FileType vhdl call VHDLColonAlign()
-augroup END
-
-function! SetAutoAlign()
-  inoremap <silent> => =><ESC>mzvip:EasyAlign/=>/<CR>`z$a
-endfunction
-
-function! VHDLChipScopeMacro()
-  let @c = "mtyiw'Sosignal \"_cs : std_logic;'Coattribute mark_debug of \"_cs : signal is \"true\";
-attribute dont_touch of \"_cs : signal is \"true\";'Do\"_cs <= \";=='t"
-endfunction
-
-function! VHDLColonAlign()
-  let g:easy_align_delimiters = {
-        \  ':': { 'pattern': ':', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0}
-        \}
-endfunction
-" }}}
 " TCL {{{
 
 augroup ft_tcl
@@ -927,7 +719,7 @@
 let g:grepper = {
       \ 'tools': ['ag', 'hg'],
       \ 'highlight': 1,
-      \ 'ag': { 
+      \ 'ag': {
       \  'grepprg': 'rg --vimgrep',
       \ }}
 
@@ -973,17 +765,7 @@
 imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'
 smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'
 
-let delimitMate_expand_cr = 1
-let delimitMate_expand_space = 1
 " }}}
-" Splice {{{
-let g:splice_initial_diff_grid=1
-let g:splice_initial_diff_compare=1
-let g:splice_initial_diff_path=0
-let g:splice_initial_scrollbind_grid=1
-let g:splice_initial_scrollbind_compare=1
-let g:splice_initial_scrollbind_path=1
-let g:splice_wrap="nowrap"
 " }}}
 " }}}