switch to lua based nvim config

This commit is contained in:
Jidbo 2022-01-23 23:24:50 +01:00 committed by saibotk
parent 21180efd69
commit 21046a4554
Signed by: saibotk
GPG key ID: 67585F0065E261D5
13 changed files with 258 additions and 306 deletions

View file

@ -1,77 +0,0 @@
" FUNCTIONS
" auto reload .vimrc on write
autocmd BufWritePost init.vim source %
" Delete buffer while keeping window layout (don't close buffer's windows).
" Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
if v:version < 700 || exists('loaded_bclose') || &cp
finish
endif
let loaded_bclose = 1
if !exists('bclose_multiple')
let bclose_multiple = 1
endif
" Display an error message.
function! s:Warn(msg)
echohl ErrorMsg
echomsg a:msg
echohl NONE
endfunction
" Command ':Bclose' executes ':bd' to delete buffer in current window.
" The window will show the alternate buffer (Ctrl-^) if it exists,
" or the previous buffer (:bp), or a blank buffer if no previous.
" Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
" An optional argument can specify which buffer to close (name or number).
function! s:Bclose(bang, buffer)
if empty(a:buffer)
let btarget = bufnr('%')
elseif a:buffer =~ '^\d\+$'
let btarget = bufnr(str2nr(a:buffer))
else
let btarget = bufnr(a:buffer)
endif
if btarget < 0
call s:Warn('No matching buffer for '.a:buffer)
return
endif
if empty(a:bang) && getbufvar(btarget, '&modified')
call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
return
endif
" Numbers of windows that view target buffer which we will delete.
let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
if !g:bclose_multiple && len(wnums) > 1
call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
return
endif
let wcurrent = winnr()
for w in wnums
execute w.'wincmd w'
let prevbuf = bufnr('#')
if prevbuf > 0 && buflisted(prevbuf) && prevbuf != btarget
buffer #
else
bprevious
endif
if btarget == bufnr('%')
" Numbers of listed buffers which are not the target to be deleted.
let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
" Listed, not target, and not displayed.
let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
" Take the first buffer, if any (could be more intelligent).
let bjump = (bhidden + blisted + [-1])[0]
if bjump > 0
execute 'buffer '.bjump
else
execute 'enew'.a:bang
endif
endif
endfor
execute 'bdelete'.a:bang.' '.btarget
execute wcurrent.'wincmd w'
endfunction
command! -bang -complete=buffer -nargs=? Bclose call <SID>Bclose(<q-bang>, <q-args>)
nnoremap <silent> <Leader>bd :Bclose<CR>

14
nvim/init.lua Normal file
View file

@ -0,0 +1,14 @@
local nvim_config_root = "~/.config/nvim"
-- BASIC OPTIONS
require('plugins')
require('options')
require('mappings')
-- VIM PLUGIN OPTIONS
vim.cmd("source " .. nvim_config_root .. "/pluginoptions.vim")
-- LUA PLUGIN OPTIONS
require('telescopeconfig')
require('autocompletion')
require('treesitterconfig')

View file

@ -1,12 +0,0 @@
let g:nvim_config_root = stdpath('config')
let g:config_file_list = [
\ 'plugins.vim',
\ 'options.vim',
\ 'mappings.vim',
\ 'functions.vim',
\ 'pluginoptions.vim',
\ ]
for f in g:config_file_list
execute 'source ' . g:nvim_config_root . '/' . f
endfor

View file

@ -10,7 +10,7 @@ cmp.setup({
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-p>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),

64
nvim/lua/mappings.lua Normal file
View file

@ -0,0 +1,64 @@
local map = function(key)
-- get the extra options
local opts = {noremap = true}
for i, v in pairs(key) do
if type(i) == 'string' then opts[i] = v end
end
-- basic support for buffer-scoped keybindings
local buffer = opts.buffer
opts.buffer = nil
if buffer then
vim.api.nvim_buf_set_keymap(0, key[1], key[2], key[3], opts)
else
vim.api.nvim_set_keymap(key[1], key[2], key[3], opts)
end
end
-- search for visual selection
map {'v', '//', 'y/<C-R>"<CR>'}
map {'n', 'H', '^'}
-- ex command
map {'c', '<C-p>', '<Up>'}
map {'c', '<C-n>', '<Down>'}
-- auto expand brackets
map {'i', '(;', '(<CR>)<C-c>O'}
map {'i', '(,', '(<CR>),<C-c>O'}
map {'i', '{;', '{<CR>}<C-c>O'}
map {'i', '{,', '{<CR>},<C-c>O'}
map {'i', '[;', '[<CR>]<C-c>O'}
map {'i', '[,', '[<CR>],<C-c>O'}
-- toggle hybrid mode
map {'n', '<leader>h', ':set rnu!<CR>'}
-- nerdtree
map {'n', '<leader>e', ':NERDTreeToggle<CR>'}
-- Telescope
map {'n', '<C-y>', '<cmd>Telescope buffers<CR>'}
map {'n', '<leader>f', '<cmd>Telescope find_files<CR>'}
map {'n', '<leader>l', '<cmd>Telescope live_grep<CR>'}
map {'n', '<silent> gD', '<cmd>Telescope lsp_implementations<CR>'}
map {'n', '<silent> gH', '<cmd>Telescope lsp_code_actions<CR>'}
map {'n', '<silent> gd', '<cmd>Telescope lsp_definitions<CR>'}
map {'n', '<silent> gr', '<cmd>Telescope lsp_references<CR>'}
map {'n', '<silent> gy', '<cmd>Telescope treesitter<CR>'}
-- neo formatter
map {'n', '<leader>p', ':Neoformat<CR>'}
-- goyo mapping
map {'n', '<silent> <leader>w', ':Goyo<CR>'}
-- spelling
map {'n', '<silent> <leader>se', ':set spell spelllang=en<CR>'}
map {'n', '<silent> <leader>sd', ':set spell spelllang=de<CR>'}
map {'n', '<silent> gh', '<cmd>lua vim.lsp.buf.hover()<CR>'}
map {'n', '<silent> gs', '<cmd>lua vim.lsp.buf.signature_help()<CR>'}
map {'n', '<silent> gR', '<cmd>lua vim.lsp.buf.rename()<CR>'}
map {'n', '<silent> ge', '<cmd>lua vim.diagnostic.open_float()<CR>'}

59
nvim/lua/options.lua Normal file
View file

@ -0,0 +1,59 @@
-- OPTIONS
-- syntax
vim.cmd [[
syntax on
let mapleader=" "
colorscheme kuroi
hi MatchParen guibg=NONE guifg=red gui=bold
set shortmess+=c
]]
-- color settings
vim.opt.termguicolors=true
vim.opt.background='dark'
-- random settings
vim.opt.number=true
vim.opt.rnu=true
vim.opt.clipboard='unnamed'
vim.opt.mouse='nvi'
vim.opt.visualbell=true
vim.opt.virtualedit='block'
vim.opt.scrolloff=1
vim.opt.wildmenu=true
vim.opt.autoread=true
vim.opt.lazyredraw=true
vim.opt.history=250
vim.opt.showmode=false
vim.opt.completeopt='menuone,noinsert,noselect'
-- tabs and line wrap
vim.opt.expandtab=true
vim.opt.tabstop=2
vim.opt.wrapmargin=8
vim.opt.softtabstop=0
vim.opt.shiftwidth=2
vim.opt.backspace='indent,eol,start'
vim.opt.encoding='utf-8'
vim.opt.autoindent=true
-- search
vim.opt.incsearch=true
vim.opt.hlsearch=true
vim.opt.smartcase=true
-- Disable Backup and Swap files
vim.opt.swapfile=false
vim.opt.backup=false
vim.opt.writebackup=false
-- setup split
vim.opt.splitbelow=true
vim.opt.splitright=true
-- Enable folding
vim.opt.foldmethod='indent'
vim.opt.foldlevel=99

91
nvim/lua/plugins.lua Normal file
View file

@ -0,0 +1,91 @@
local Plug = vim.fn['plug#']
-- PLUGINS
vim.call('plug#begin', '~/.config/nvim/bundle')
-- USEFUL
-- ===================
-- Editor config
Plug 'editorconfig/editorconfig-vim'
-- brackets management
Plug 'tpope/vim-surround'
-- new text objects
Plug 'wellle/targets.vim'
-- WINDOW MANAGEMENT
-- ===================
-- tmux navigator
Plug 'christoomey/vim-tmux-navigator'
-- winresizer
Plug 'simeji/winresizer'
-- goyo
Plug 'junegunn/goyo.vim'
-- FILE MANAGEMENT
-- ===================
-- nerd-tree
Plug 'preservim/nerdtree'
-- Icons
Plug 'ryanoasis/vim-devicons'
-- fzf plugin
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
-- vimwiki
Plug 'vimwiki/vimwiki'
-- GIT STUFF
-- ===================
-- git
Plug 'tpope/vim-fugitive'
-- vim gitgutter
Plug 'airblade/vim-gitgutter'
-- COLORS
-- ===================
-- Plastic colorscheme
Plug 'jidbo/kuroi.vim'
-- Color higlighting
Plug 'norcalli/nvim-colorizer.lua'
-- powerline
Plug 'vim-airline/vim-airline'
-- LANGUAGES
-- ===================
-- nvim completion
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'SirVer/ultisnips'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
-- Autoformatter
Plug 'sbdchd/neoformat'
-- treesitter
Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'})
-- latex
Plug 'lervag/vimtex'
-- All of your Plugins must be added before the following line
vim.call('plug#end')

View file

@ -0,0 +1,21 @@
-- load telescope
-- require("telescope").setup {
-- extensions = {
-- file_browser = {
-- -- theme = "ivy",
-- -- initial_mode = "normal",
-- mappings = {
-- ["i"] = {
-- ["<C-->"] = fb_actions.goto_parent_dir,
-- },
-- ["n"] = {
-- ["b"] = fb_actions.goto_parent_dir,
-- },
-- },
-- },
-- },
-- }
--
-- -- plugins
-- require("telescope").load_extension "file_browser"

View file

@ -0,0 +1,8 @@
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
indent = {
enable = true
},
}

View file

@ -1,53 +0,0 @@
" REMAPS
" search for visual selection
vnoremap // y/<C-R>"<CR>
nnoremap H ^
" ex command
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
" auto expand brackets
inoremap (; (<CR>)<C-c>O
inoremap (, (<CR>),<C-c>O
inoremap {; {<CR>}<C-c>O
inoremap {, {<CR>},<C-c>O
inoremap [; [<CR>]<C-c>O
inoremap [, [<CR>],<C-c>O
" toggle hybrid mode
nnoremap <leader>h :set rnu!<CR>
" nerdtree
map <leader>e :NERDTreeToggle<CR>
" Telescope
nnoremap <C-y> <cmd>Telescope buffers<CR>
nnoremap <leader>f <cmd>Telescope find_files<CR>
nnoremap <leader>l <cmd>Telescope live_grep<CR>
nnoremap <silent> gD <cmd>Telescope lsp_implementations<CR>
nnoremap <silent> gH <cmd>Telescope lsp_code_actions<CR>
nnoremap <silent> gd <cmd>Telescope lsp_definitions<CR>
nnoremap <silent> gr <cmd>Telescope lsp_references<CR>
nnoremap <silent> gy <cmd>Telescope treesitter<CR>
" vim fugitive
nnoremap <leader>gg :G<cr>
" neo formatter
nnoremap <leader>p :Neoformat<CR>
" goyo mapping
nnoremap <silent> <leader>w :Goyo<CR>
" spelling
nnoremap <silent> <leader>se :set spell spelllang=en<CR>
nnoremap <silent> <leader>sd :set spell spelllang=de<CR>
" nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> gh <cmd>lua vim.lsp.buf.hover()<CR>
" nnoremap <silent> gH <cmd>lua vim.lsp.buf.code_action()<CR>
" nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> gs <cmd>lua vim.lsp.buf.signature_help()<CR>
" nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> gR <cmd>lua vim.lsp.buf.rename()<CR>

View file

@ -1,59 +0,0 @@
" OPTIONS
" syntax
syntax on
let mapleader=" "
" color settings
set termguicolors
colorscheme kuroi
set background=dark
hi MatchParen guibg=NONE guifg=red gui=bold
" random settings
set number
set rnu
set clipboard=unnamed
set mouse=nvi
" set smarttab
set expandtab
set tabstop=4
set visualbell
set virtualedit=block
set scrolloff=1
set wildmenu
set autoread
set lazyredraw
set history=250
set noshowmode
" tabs and line wrap
set wrapmargin=8
set softtabstop=0 noexpandtab
set shiftwidth=4
set backspace=2
set backspace=indent,eol,start
set encoding=utf-8
set autoindent
" search
set incsearch
set hlsearch
set smartcase
" Disable Backup and Swap files
set noswapfile
set nobackup
set nowritebackup
" setup split
set splitbelow
set splitright
" Enable folding
set foldmethod=indent
set foldlevel=99
" highlight yanked
au TextYankPost * silent! lua vim.highlight.on_yank()

View file

@ -100,22 +100,3 @@ autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
let g:goyo_width = 120
" AUTOCOMPLETION
" =========================
set completeopt=menuone,noinsert,noselect
set shortmess+=c
lua require('autocompletion')
" TREESITTER
lua <<EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
indent = {
enable = true
},
}
EOF

View file

@ -1,85 +0,0 @@
" PLUGINS
call plug#begin('~/.config/nvim/bundle')
" USEFUL
" ===================
" Editor config
Plug 'editorconfig/editorconfig-vim'
" brackets management
Plug 'tpope/vim-surround'
" WINDOW MANAGEMENT
" ===================
" tmux navigator
Plug 'christoomey/vim-tmux-navigator'
" winresizer
Plug 'simeji/winresizer'
" goyo
Plug 'junegunn/goyo.vim'
" FILE MANAGEMENT
" ===================
" nerd-tree
Plug 'preservim/nerdtree'
" Icons
Plug 'ryanoasis/vim-devicons'
" fzf plugin
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
" vimwiki
Plug 'vimwiki/vimwiki'
" GIT STUFF
" ===================
" git
Plug 'tpope/vim-fugitive'
" vim gitgutter
Plug 'airblade/vim-gitgutter'
" COLORS
" ===================
" Plastic colorscheme
Plug 'jidbo/kuroi.vim'
" Color higlighting
Plug 'norcalli/nvim-colorizer.lua'
" powerline
Plug 'vim-airline/vim-airline'
" LANGUAGES
" ===================
" nvim completion
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'SirVer/ultisnips'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
" Autoformatter
Plug 'sbdchd/neoformat'
" treesitter
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" latex
Plug 'lervag/vimtex'
" All of your Plugins must be added before the following line
call plug#end()