From 0fcc53b2cf0c88a75082fb763c46c9b13ee6df48 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Mon, 3 Jan 2022 23:45:30 +0100 Subject: [PATCH] Put configuration elements in different files --- conf/nvim/init.lua | 175 +----------------------------- conf/nvim/lua/functions.lua | 17 +++ conf/nvim/lua/keybiding.lua | 32 ++++++ conf/nvim/lua/plugins-options.lua | 26 +++++ conf/nvim/lua/plugins.lua | 24 ++++ conf/nvim/lua/settings.lua | 67 ++++++++++++ 6 files changed, 171 insertions(+), 170 deletions(-) create mode 100644 conf/nvim/lua/functions.lua create mode 100644 conf/nvim/lua/keybiding.lua create mode 100644 conf/nvim/lua/plugins-options.lua create mode 100644 conf/nvim/lua/plugins.lua create mode 100644 conf/nvim/lua/settings.lua diff --git a/conf/nvim/init.lua b/conf/nvim/init.lua index 8f513f3..52d6e66 100644 --- a/conf/nvim/init.lua +++ b/conf/nvim/init.lua @@ -1,170 +1,5 @@ - ---Plugins ---cmd 'packadd paq-nvim -local paq = require("paq") -paq { - "savq/paq-nvim"; - -- vim airline and vim airline theme - 'vim-airline/vim-airline'; - -- vim airline and vim airline theme - 'vim-airline/vim-airline-themes'; - 'w0rp/ale'; - -- Base16 theme - 'chriskempson/base16-vim'; - - -- NERDTree file manager - 'scrooloose/nerdtree'; - - -- Vim fugitive - 'tpope/vim-fugitive'; - 'tpope/vim-surround'; - 'sheerun/vim-polyglot'; - {'Shougo/deoplete.nvim', run = vim.fn['remote#host#UpdateRemotePlugins']}; - 'zchee/deoplete-jedi'; - -- Grammalecte - 'dpelle/vim-Grammalecte'; -} - - --- General Option -vim.opt.autoindent = true -vim.opt.background = 'dark' -vim.opt.backupdir = os.getenv("HOME") .. '/.local/tmp/nvim' -vim.opt.clipboard = 'unnamedplus' --Use system clipboard -vim.opt.colorcolumn = '80' -vim.opt.directory = os.getenv("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 pumvisible()? "\" : "\" --- inoremap pumvisible()? "\" : "\" - - -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', noremap = false, silent = true} --- map {'', '[C-right]', ':tabnext', noremap = false, silent = true} -map {'n', '/', ':nohlsearch', noremap = false, silent = true} -map {'n', '', ':NERDTreeToggle', noremap = false, silent = true} - --- Move tabs with \[ and \] -map {'n', ']', ':tabnext', noremap = false, silent = true} -map {'n', '[', ':tabprev', noremap = false, silent = true} -map {'n', 'l', ':set list!', 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'' - else - return t'' - end -end - -vim.api.nvim_set_keymap( - 'i', - '', - '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?' -} +require("functions") +require("settings") +require("plugins") +require("plugins-options") +require("keybiding") diff --git a/conf/nvim/lua/functions.lua b/conf/nvim/lua/functions.lua new file mode 100644 index 0000000..5e955f9 --- /dev/null +++ b/conf/nvim/lua/functions.lua @@ -0,0 +1,17 @@ +function map(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 diff --git a/conf/nvim/lua/keybiding.lua b/conf/nvim/lua/keybiding.lua new file mode 100644 index 0000000..7d0b87e --- /dev/null +++ b/conf/nvim/lua/keybiding.lua @@ -0,0 +1,32 @@ + +-- " Key biding +-- " ---------- +-- map {'', '[C-left]', ':tabprevious', noremap = false, silent = true} +-- map {'', '[C-right]', ':tabnext', noremap = false, silent = true} +map {'n', '/', ':nohlsearch', noremap = false, silent = true} +map {'n', '', ':NERDTreeToggle', noremap = false, silent = true} + +-- Move tabs with \[ and \] +map {'n', ']', ':tabnext', noremap = false, silent = true} +map {'n', '[', ':tabprev', noremap = false, silent = true} +map {'n', 'l', ':set list!', 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'' + else + return t'' + end +end + +vim.api.nvim_set_keymap( + 'i', + '', + 'v:lua.smart_tab()', + {noremap = true, expr = true} +) diff --git a/conf/nvim/lua/plugins-options.lua b/conf/nvim/lua/plugins-options.lua new file mode 100644 index 0000000..2c5c315 --- /dev/null +++ b/conf/nvim/lua/plugins-options.lua @@ -0,0 +1,26 @@ +-- 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%]' + +-- 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 diff --git a/conf/nvim/lua/plugins.lua b/conf/nvim/lua/plugins.lua new file mode 100644 index 0000000..067c863 --- /dev/null +++ b/conf/nvim/lua/plugins.lua @@ -0,0 +1,24 @@ +--Plugins +local paq = require("paq") +paq { + "savq/paq-nvim"; + -- vim airline and vim airline theme + 'vim-airline/vim-airline'; + -- vim airline and vim airline theme + 'vim-airline/vim-airline-themes'; + 'w0rp/ale'; + -- Base16 theme + 'chriskempson/base16-vim'; + + -- NERDTree file manager + 'scrooloose/nerdtree'; + + -- Vim fugitive + 'tpope/vim-fugitive'; + 'tpope/vim-surround'; + 'sheerun/vim-polyglot'; + {'Shougo/deoplete.nvim', run = vim.fn['remote#host#UpdateRemotePlugins']}; + 'zchee/deoplete-jedi'; + -- Grammalecte + 'dpelle/vim-Grammalecte'; +} diff --git a/conf/nvim/lua/settings.lua b/conf/nvim/lua/settings.lua new file mode 100644 index 0000000..97ebb92 --- /dev/null +++ b/conf/nvim/lua/settings.lua @@ -0,0 +1,67 @@ +-- General Option +vim.opt.autoindent = true +vim.opt.background = 'dark' +vim.opt.backupdir = os.getenv("HOME") .. '/.local/tmp/nvim' +vim.opt.clipboard = 'unnamedplus' --Use system clipboard +vim.opt.colorcolumn = '80' +vim.opt.directory = os.getenv("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') + +-- -- Code Fold +-- "Load and save view atomatocally (save and restore fold) +vim.cmd('au BufWinLeave *.* mkview') +vim.cmd('au BufWinEnter *.* silent! loadview') + +-- inoremap pumvisible()? "\" : "\" +-- inoremap pumvisible()? "\" : "\" + + + +-- 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?' +}