Update configuration to Lua
This commit is contained in:
parent
4d3267b702
commit
0d9cc47300
2 changed files with 174 additions and 149 deletions
174
conf/nvim/init.lua
Normal file
174
conf/nvim/init.lua
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
|
||||||
|
--Plug init
|
||||||
|
--
|
||||||
|
local Plug = vim.fn['plug#']
|
||||||
|
vim.call('plug#begin', '~/.local/lib/nvim/plugged')
|
||||||
|
|
||||||
|
-- vim airline and vim airline theme
|
||||||
|
Plug 'vim-airline/vim-airline'
|
||||||
|
-- vim airline and vim airline theme
|
||||||
|
Plug 'vim-airline/vim-airline-themes'
|
||||||
|
|
||||||
|
Plug 'w0rp/ale'
|
||||||
|
|
||||||
|
-- Base16 theme
|
||||||
|
Plug 'chriskempson/base16-vim'
|
||||||
|
|
||||||
|
-- NERDTree file manager
|
||||||
|
Plug 'scrooloose/nerdtree'
|
||||||
|
|
||||||
|
-- Vim fugitive
|
||||||
|
Plug 'tpope/vim-fugitive'
|
||||||
|
Plug 'tpope/vim-surround'
|
||||||
|
Plug 'sheerun/vim-polyglot'
|
||||||
|
|
||||||
|
Plug('Shougo/deoplete.nvim', { ['do'] = ':UpdateRemotePlugins' })
|
||||||
|
Plug 'zchee/deoplete-jedi'
|
||||||
|
|
||||||
|
-- Grammalecte
|
||||||
|
Plug('dpelle/vim-Grammalecte', { on = 'GrammalecteCheck' })
|
||||||
|
|
||||||
|
vim.call('plug#end')
|
||||||
|
|
||||||
|
-- General Option
|
||||||
|
vim.opt.autoindent = true
|
||||||
|
vim.opt.background = 'dark'
|
||||||
|
vim.opt.backupdir = '$HOME/.local/tmp/nvim'
|
||||||
|
vim.opt.clipboard = 'unnamedplus' --Use system clipboard
|
||||||
|
vim.opt.colorcolumn = '80'
|
||||||
|
vim.opt.directory = '$HOME/.local/tmp/nvim'
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
vim.opt.foldmethod = 'syntax'
|
||||||
|
vim.opt.gdefault = true -- search: all occurrences by default
|
||||||
|
vim.opt.hlsearch = true -- search: hightlight terms
|
||||||
|
vim.opt.ignorecase = true
|
||||||
|
vim.opt.incsearch = true
|
||||||
|
vim.opt.laststatus = 1
|
||||||
|
-- show special character
|
||||||
|
vim.opt.listchars = {tab = '→ ', trail = '␣', eol = '', extends = '…' }
|
||||||
|
|
||||||
|
vim.opt.number = true
|
||||||
|
vim.opt.shiftwidth = 4
|
||||||
|
vim.opt.showmatch = true
|
||||||
|
vim.opt.smartcase = true -- search: try :to be smart about cases
|
||||||
|
vim.opt.smartindent = true
|
||||||
|
vim.opt.tabstop = 4
|
||||||
|
vim.opt.termguicolors = true -- 24 bits color support
|
||||||
|
vim.opt.wildmenu = true -- activate enhanced user menu
|
||||||
|
vim.opt.wildmode = 'lastused:full,list' -- enhance menu
|
||||||
|
|
||||||
|
-- Options than need vim.cmd
|
||||||
|
vim.cmd('syntax on')
|
||||||
|
vim.cmd('colorscheme base16-classic-dark')
|
||||||
|
|
||||||
|
-- Global variables
|
||||||
|
vim.g['base16colorspace'] = 256
|
||||||
|
|
||||||
|
-- Vim-airLine
|
||||||
|
vim.g['airline#extensions#tabline#enabled'] = 1
|
||||||
|
vim.g['airline#extensions#tabline#left_sep'] = ''
|
||||||
|
vim.g['airline#extensions#tabline#left_alt_sep'] = '|'
|
||||||
|
vim.g['g:airline_powerline_fonts'] = 1
|
||||||
|
vim.g['airline_skip_empty_sections'] = 1
|
||||||
|
vim.g['airline#extensions#tabline#show_splits'] = 0
|
||||||
|
|
||||||
|
-- ALE
|
||||||
|
vim.g['ale_sign_column_always'] = 1
|
||||||
|
vim.g['ale_sign_error'] = '⚠'
|
||||||
|
vim.g['ale_sign_warning'] = '⚠'
|
||||||
|
vim.g['ale_echo_msg_format'] = '[%linter%] %s [%severity%]'
|
||||||
|
|
||||||
|
-- -- Code Fold
|
||||||
|
-- "Load and save view atomatocally (save and restore fold)
|
||||||
|
vim.cmd('au BufWinLeave *.* mkview')
|
||||||
|
vim.cmd('au BufWinEnter *.* silent! loadview')
|
||||||
|
|
||||||
|
-- NerdTree
|
||||||
|
-- Close NERDTree if it is the last buffer open
|
||||||
|
vim.cmd('au bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif')
|
||||||
|
|
||||||
|
-- Grammalecte
|
||||||
|
vim.g['grammalecte_cli_py'] = '/usr/bin/grammalecte-cli'
|
||||||
|
|
||||||
|
-- Deoplete
|
||||||
|
vim.g['deoplete#enable_at_startup'] = 1
|
||||||
|
-- inoremap <silent><expr><tab> pumvisible()? "\<c-n>" : "\<tab>"
|
||||||
|
-- inoremap <silent><expr><s-tab> pumvisible()? "\<c-p>" : "\<s-tab>"
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-- " Key biding
|
||||||
|
-- " ----------
|
||||||
|
-- map {'', '[C-left]', ':tabprevious<CR>', noremap = false, silent = true}
|
||||||
|
-- map {'', '[C-right]', ':tabnext<CR>', noremap = false, silent = true}
|
||||||
|
map {'n', '<leader>/', ':nohlsearch<CR>', noremap = false, silent = true}
|
||||||
|
map {'n', '<F2>', ':NERDTreeToggle<CR>', noremap = false, silent = true}
|
||||||
|
|
||||||
|
-- Move tabs with \[ and \]
|
||||||
|
map {'n', '<Leader>]', ':tabnext<CR>', noremap = false, silent = true}
|
||||||
|
map {'n', '<Leader>[', ':tabprev<CR>', noremap = false, silent = true}
|
||||||
|
map {'n', '<leader>l', ':set list!<CR>', silent = true}
|
||||||
|
|
||||||
|
-- Manage Tab
|
||||||
|
local t = function(str)
|
||||||
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
_G.smart_tab = function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return t'<C-n>'
|
||||||
|
else
|
||||||
|
return t'<Tab>'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap(
|
||||||
|
'i',
|
||||||
|
'<Tab>',
|
||||||
|
'v:lua.smart_tab()',
|
||||||
|
{noremap = true, expr = true}
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Autotype
|
||||||
|
vim.cmd('au BufRead,BufNewFile *.md setlocal textwidth=80')
|
||||||
|
vim.cmd('au BufRead,BufNewFile *.tex setlocal textwidth=80')
|
||||||
|
vim.cmd('au BufNewFile,BufRead /tmp/neomutt* set tw=72 fo=awq comments+=nb:> noautoindent filetype=mail')
|
||||||
|
|
||||||
|
-- Ignore these filenames during enhanced command line completion.
|
||||||
|
vim.opt.wildignore = {
|
||||||
|
'*.bak',
|
||||||
|
'*.class',
|
||||||
|
'*.aux',
|
||||||
|
'*.out',
|
||||||
|
'*.toc',
|
||||||
|
'*.jpg',
|
||||||
|
'*.bmp',
|
||||||
|
'*.gif',
|
||||||
|
'*.png',
|
||||||
|
'*.luac',
|
||||||
|
'*.o',
|
||||||
|
'*.obj',
|
||||||
|
'*.exe',
|
||||||
|
'*.dll',
|
||||||
|
'*.manifest',
|
||||||
|
'*.pyc',
|
||||||
|
'*.spl',
|
||||||
|
'*.sw?'
|
||||||
|
}
|
|
@ -1,149 +0,0 @@
|
||||||
set nocompatible
|
|
||||||
|
|
||||||
"Plug init
|
|
||||||
"
|
|
||||||
call plug#begin('~/.local/lib/nvim/plugged')
|
|
||||||
|
|
||||||
"vim airline and vim airline theme
|
|
||||||
Plug 'vim-airline/vim-airline'
|
|
||||||
"vim airline and vim airline theme
|
|
||||||
Plug 'vim-airline/vim-airline-themes'
|
|
||||||
|
|
||||||
if v:version >= 800
|
|
||||||
" Replace syntastic with ale (test)
|
|
||||||
Plug 'w0rp/ale'
|
|
||||||
endif
|
|
||||||
|
|
||||||
"Base16 theme
|
|
||||||
Plug 'chriskempson/base16-vim'
|
|
||||||
|
|
||||||
"NERDTree file manager
|
|
||||||
Plug 'scrooloose/nerdtree'
|
|
||||||
|
|
||||||
"Vim fugitive
|
|
||||||
Plug 'tpope/vim-fugitive'
|
|
||||||
Plug 'tpope/vim-surround'
|
|
||||||
Plug 'sheerun/vim-polyglot'
|
|
||||||
|
|
||||||
if has('nvim')
|
|
||||||
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
||||||
endif
|
|
||||||
Plug 'zchee/deoplete-jedi'
|
|
||||||
|
|
||||||
"Grammalecte
|
|
||||||
Plug 'dpelle/vim-Grammalecte', { 'on': 'GrammalecteCheck' }
|
|
||||||
|
|
||||||
call plug#end()
|
|
||||||
|
|
||||||
filetype plugin indent on
|
|
||||||
syntax enable
|
|
||||||
set title
|
|
||||||
set nu
|
|
||||||
set showmode
|
|
||||||
set noswapfile
|
|
||||||
set nofsync
|
|
||||||
set buftype=
|
|
||||||
set mouse=a
|
|
||||||
set encoding=utf8
|
|
||||||
set directory^=$HOME/.local/tmp/nvim
|
|
||||||
set backupdir^=$HOME/.local/tmp/nvim
|
|
||||||
set smartindent
|
|
||||||
set tabstop=4
|
|
||||||
set shiftwidth=4
|
|
||||||
set expandtab
|
|
||||||
set showmatch
|
|
||||||
set colorcolumn=80
|
|
||||||
set clipboard+=unnamedplus "Use system clipboard
|
|
||||||
|
|
||||||
"Code Fold
|
|
||||||
"---------
|
|
||||||
set foldmethod=indent
|
|
||||||
"Load and save view atomatocally (save and restore fold)
|
|
||||||
autocmd BufWinLeave *.* mkview
|
|
||||||
autocmd BufWinEnter *.* silent! loadview
|
|
||||||
|
|
||||||
"Searching
|
|
||||||
"---------
|
|
||||||
set incsearch " Ignore case when searching
|
|
||||||
set ignorecase
|
|
||||||
set smartcase " When searching try to be smart about cases
|
|
||||||
set hlsearch " hightlight search terms
|
|
||||||
set gdefault " Search all occurrences by default
|
|
||||||
|
|
||||||
" NerdTree
|
|
||||||
" --------
|
|
||||||
" Close NERDTree if it is the last buffer open
|
|
||||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
|
||||||
|
|
||||||
" ALE (test)
|
|
||||||
" ----------
|
|
||||||
let g:ale_sign_column_always = 1
|
|
||||||
let g:ale_sign_error = '⚠'
|
|
||||||
let g:ale_sign_warning = '⚠'
|
|
||||||
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
|
|
||||||
|
|
||||||
" Vim-airLine
|
|
||||||
" -----------
|
|
||||||
|
|
||||||
let g:airline#extensions#tabline#enabled = 1
|
|
||||||
let g:airline#extensions#tabline#left_sep = ''
|
|
||||||
let g:airline#extensions#tabline#left_alt_sep = '|'
|
|
||||||
let g:airline_powerline_fonts = 1
|
|
||||||
let g:airline_skip_empty_sections = 1
|
|
||||||
"let g:airline#extensions#bufferline#enabled = 1
|
|
||||||
let g:airline#extensions#tabline#show_splits = 0
|
|
||||||
|
|
||||||
" Grammalecte
|
|
||||||
" -----------
|
|
||||||
|
|
||||||
let g:grammalecte_cli_py='/usr/bin/grammalecte-cli'
|
|
||||||
|
|
||||||
"set laststatus=2
|
|
||||||
|
|
||||||
set laststatus
|
|
||||||
" Deoplete
|
|
||||||
" --------
|
|
||||||
let g:deoplete#enable_at_startup = 1
|
|
||||||
" Deoplete tab order on popup to be down/up instead of up/down
|
|
||||||
inoremap <silent><expr><tab> pumvisible()? "\<c-n>" : "\<tab>"
|
|
||||||
inoremap <silent><expr><s-tab> pumvisible()? "\<c-p>" : "\<s-tab>"
|
|
||||||
|
|
||||||
" Color Scheme
|
|
||||||
" ------------
|
|
||||||
set termguicolors "24 bits color support
|
|
||||||
let base16colorspace=256
|
|
||||||
colorscheme base16-classic-dark
|
|
||||||
set background=dark
|
|
||||||
|
|
||||||
" Key biding
|
|
||||||
" ----------
|
|
||||||
map <silent> [C-left] :tabprevious<CR>
|
|
||||||
map <silent> [C-right] :tabnext<CR>
|
|
||||||
map <silent> <leader>/ :nohlsearch<CR>
|
|
||||||
map <silent> <F2> :NERDTreeToggle<CR>
|
|
||||||
" Move tabs with \[ and \]
|
|
||||||
map <Leader>] :tabnext<CR>
|
|
||||||
map <Leader>[ :tabprev<CR>
|
|
||||||
" show special character
|
|
||||||
set listchars=tab:→\ ,trail:␣,extends:…,eol:
|
|
||||||
nmap <leader>l :set list!<CR>
|
|
||||||
|
|
||||||
" Autotype
|
|
||||||
" --------
|
|
||||||
au BufRead,BufNewFile *.md setlocal textwidth=80
|
|
||||||
au BufRead,BufNewFile *.tex setlocal textwidth=80
|
|
||||||
autocmd BufNewFile,BufRead /tmp/neomutt* set tw=72 fo=awq comments+=nb:> noautoindent filetype=mail
|
|
||||||
|
|
||||||
" Enable enhanced command line completion.
|
|
||||||
set wildmenu
|
|
||||||
set wildmode=longest:full,list
|
|
||||||
|
|
||||||
" Ignore these filenames during enhanced command line completion.
|
|
||||||
set wildignore+=*.bak,*.class
|
|
||||||
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
|
|
||||||
set wildignore+=*.jpg,*.bmp,*.gif,*.png " binary images
|
|
||||||
set wildignore+=*.luac " Lua byte code
|
|
||||||
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
|
|
||||||
set wildignore+=*.pyc " Python byte code
|
|
||||||
set wildignore+=*.spl " compiled spelling word lists
|
|
||||||
set wildignore+=*.sw? " Vim swap files
|
|
Loading…
Add table
Add a link
Reference in a new issue