From b99646214fda54c6b558cc4267999fc099fd77a6 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Mon, 2 Aug 2021 08:36:58 +0200 Subject: [PATCH] Feat: import nvim config --- nvim/.config/nvim/general/completion.vim | 18 ++++++ nvim/.config/nvim/general/mappings.vim | 19 ++++++ nvim/.config/nvim/general/settings.vim | 66 +++++++++++++++++++++ nvim/.config/nvim/init.vim | 14 +++++ nvim/.config/nvim/lua/lsp.lua | 58 ++++++++++++++++++ nvim/.config/nvim/plug-config/lightline.vim | 10 ++++ nvim/.config/nvim/plug-config/vimtex.vim | 25 ++++++++ nvim/.config/nvim/vim-plug/plugins.vim | 41 +++++++++++++ 8 files changed, 251 insertions(+) create mode 100644 nvim/.config/nvim/general/completion.vim create mode 100644 nvim/.config/nvim/general/mappings.vim create mode 100644 nvim/.config/nvim/general/settings.vim create mode 100644 nvim/.config/nvim/init.vim create mode 100644 nvim/.config/nvim/lua/lsp.lua create mode 100644 nvim/.config/nvim/plug-config/lightline.vim create mode 100644 nvim/.config/nvim/plug-config/vimtex.vim create mode 100644 nvim/.config/nvim/vim-plug/plugins.vim diff --git a/nvim/.config/nvim/general/completion.vim b/nvim/.config/nvim/general/completion.vim new file mode 100644 index 0000000..e914599 --- /dev/null +++ b/nvim/.config/nvim/general/completion.vim @@ -0,0 +1,18 @@ +" Use completion-nvim in every buffer +autocmd BufEnter * lua require'completion'.on_attach() + +let g:completion_enable_snippet = 'UltiSnips' +let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy'] + +" Use and to navigate through popup menu +" inoremap pumvisible() ? "\" : "\" +" inoremap pumvisible() ? "\" : "\" + +"map to manually trigger completion +"imap (completion_trigger) + +" Set completeopt to have a better completion experience +set completeopt=menuone,noinsert,noselect + +" Avoid showing message extra message when using completion +set shortmess+=c diff --git a/nvim/.config/nvim/general/mappings.vim b/nvim/.config/nvim/general/mappings.vim new file mode 100644 index 0000000..d9453b9 --- /dev/null +++ b/nvim/.config/nvim/general/mappings.vim @@ -0,0 +1,19 @@ +" Better window navigation +" nnoremap h +" nnoremap j +" nnoremap k +" nnoremap l + +" Align blocks of text and keep them selected +vmap < >gv + +" Automatically spell check last error in insert mode +inoremap u[s1z=`]au + +" Find files using Telescope command-line sugar. +nnoremap e Telescope find_files +nnoremap g Telescope live_grep +nnoremap b Telescope buffers +nnoremap h Telescope help_tags + diff --git a/nvim/.config/nvim/general/settings.vim b/nvim/.config/nvim/general/settings.vim new file mode 100644 index 0000000..43f522b --- /dev/null +++ b/nvim/.config/nvim/general/settings.vim @@ -0,0 +1,66 @@ +" set leader key +let g:mapleader = "\" + +syntax enable " Enables syntax highlighing +set hidden " Required to keep multiple buffers open multiple buffers +set wrap " Display long lines as just one line +set pumheight=10 " Makes popup menu smaller +set encoding=utf-8 " The encoding displayed +set fileencoding=utf-8 " The encoding written to file +set ruler " Show the cursor position all the time +set cmdheight=1 " More space for displaying messages +set iskeyword+=- " treat dash separated words as a word text object" +set mouse=a " Enable your mouse +set t_Co=256 " Support 256 colors + +set conceallevel=0 " So that I can see `` in markdown files +set tabstop=4 " Insert 2 spaces for a tab +set shiftwidth=4 " Change the number of space characters inserted for indentation +set smarttab " Makes tabbing smarter will realize you have 2 vs 4 +set expandtab " Converts tabs to spaces +set smartindent " Makes indenting smart +set autoindent " Good auto indent +set foldmethod=indent + +set laststatus=2 " Always display the status line + +set number " Line number +set relativenumber " Relative line number +set cursorline " Enable highlighting of the current line +set showtabline=1 " show tabs only when there are some + +set background=dark " tell vim what the background color looks like + +set nobackup " This is recommended by coc +set nowritebackup " This is recommended by coc +set noswapfile + +set updatetime=300 " Faster completion +set timeoutlen=500 " By default timeoutlen is 1000 ms + +set clipboard=unnamedplus " Copy paste between vim and everything else + +set showmode " Display edition mode +"set noshowmode " We don't need to see things like -- INSERT -- anymore + +set incsearch " hightlight while searching +set ignorecase " Ignore case while searching +set smartcase " Override ignorecase if search patern contains upper case +set wildmenu " Enable wildmenu + +set spell " Enable spell checking +set spelllang=fr,en + +set nrformats+=alpha " letter concidered as number for Ctrl-A or Ctrl-X + +"set autochdir " Your working directory will always be the same as your working directory + +execute "set colorcolumn=" . join(range(81,335), ',') + +colorscheme zenburn + +" Set completeopt to have a better completion experience +set completeopt=menuone,noinsert,noselect + +" Avoid showing message extra message when using completion +set shortmess+=c diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim new file mode 100644 index 0000000..bd97fe1 --- /dev/null +++ b/nvim/.config/nvim/init.vim @@ -0,0 +1,14 @@ +source $HOME/.config/nvim/vim-plug/plugins.vim +source $HOME/.config/nvim/general/settings.vim +source $HOME/.config/nvim/general/mappings.vim +source $HOME/.config/nvim/general/completion.vim + +source $HOME/.config/nvim/plug-config/lightline.vim + +lua < + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + -- See references + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + -- show documentation + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + -- Rename + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + + -- je sais pas ce c'est que ces workspaces + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + -- ?? + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + -- Details on diagnostics + buf_set_keymap('n', 'd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + -- Cycle over diagnostics + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + -- Get diagnostic on local list + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) + + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) +end + +-- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { "pyright" } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + } + } +end diff --git a/nvim/.config/nvim/plug-config/lightline.vim b/nvim/.config/nvim/plug-config/lightline.vim new file mode 100644 index 0000000..328e353 --- /dev/null +++ b/nvim/.config/nvim/plug-config/lightline.vim @@ -0,0 +1,10 @@ +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'gitbranch', 'readonly', 'relativepath', 'modified'] ] + \ }, + \ 'component_function': { + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } diff --git a/nvim/.config/nvim/plug-config/vimtex.vim b/nvim/.config/nvim/plug-config/vimtex.vim new file mode 100644 index 0000000..210236f --- /dev/null +++ b/nvim/.config/nvim/plug-config/vimtex.vim @@ -0,0 +1,25 @@ +let maplocalleader = "\" + +let g:tex_conceal = "" +set conceallevel=0 + +let g:vimtex_compiler_latexmk = { + \ 'backend' : 'nvim', + \ 'background' : 1, + \ 'build_dir' : '', + \ 'callback' : 0, + \ 'continuous' : 1, + \ 'options' : [ + \ '-pdf', + \ '-verbose', + \ '-file-line-error', + \ '-synctex=1', + \ '-interaction=nonstopmode', + \ '-silent', + \ '-shell-escape', + \ ], + \} +let g:vimtex_view_method = 'zathura' + +" Les fichiers sty et cls sont vus comme des fichiers tex +autocmd BufRead,BufNewFile *.{sty,cls} setlocal syntax=tex diff --git a/nvim/.config/nvim/vim-plug/plugins.vim b/nvim/.config/nvim/vim-plug/plugins.vim new file mode 100644 index 0000000..47f2874 --- /dev/null +++ b/nvim/.config/nvim/vim-plug/plugins.vim @@ -0,0 +1,41 @@ +" auto-install vim-plug +if empty(glob('~/.config/nvim/autoload/plug.vim')) + silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + "autocmd VimEnter * PlugInstall + "autocmd VimEnter * PlugInstall | source $MYVIMRC +endif + +call plug#begin('~/.config/nvim/autoload/plugged') + + Plug 'jnurmine/Zenburn' + Plug 'itchyny/lightline.vim' + + "Plug 'tpope/vim-sensible' + Plug 'tpope/vim-fugitive' + Plug 'tpope/vim-surround' + Plug 'tpope/vim-repeat' + + Plug 'junegunn/goyo.vim' + Plug 'christoomey/vim-tmux-navigator' + Plug 'Yggdroot/indentLine' + + Plug 'neovim/nvim-lspconfig' + " Plug 'hrsh7th/nvim-compe' + Plug 'nvim-lua/completion-nvim' + + Plug 'nvim-lua/popup.nvim' + Plug 'nvim-lua/plenary.nvim' + Plug 'nvim-telescope/telescope.nvim' + + "Plug 'lervag/vimtex' + + Plug 'SirVer/ultisnips' + Plug 'honza/vim-snippets' + + Plug 'mhinz/vim-signify' + Plug 'tpope/vim-fugitive' + + Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +call plug#end()