From 6829f756395dc49ca36fb87d7cd6dedf3301b4bc Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Fri, 15 Apr 2022 16:32:43 +0200 Subject: [PATCH] Not gook big commit... --- README.md | 21 ++++++++++------ conf/nvim/lua/keybiding.lua | 21 ++++++++-------- conf/nvim/lua/plugins-options.lua | 28 ++++----------------- conf/nvim/lua/plugins.lua | 35 +++++++++++++------------- conf/nvim/lua/plugins/cmp.lua | 37 ++++++++++++++++++++++++++++ conf/nvim/lua/plugins/gitsigns.lua | 3 +++ conf/nvim/lua/plugins/lsp.lua | 23 +++++++++++++++++ conf/nvim/lua/plugins/lualine.lua | 29 ++++++++++++++++++++++ conf/nvim/lua/plugins/treesitter.lua | 12 +++++++++ conf/nvim/lua/settings.lua | 14 +++++++++-- 10 files changed, 162 insertions(+), 61 deletions(-) create mode 100644 conf/nvim/lua/plugins/cmp.lua create mode 100644 conf/nvim/lua/plugins/gitsigns.lua create mode 100644 conf/nvim/lua/plugins/lsp.lua create mode 100644 conf/nvim/lua/plugins/lualine.lua create mode 100644 conf/nvim/lua/plugins/treesitter.lua diff --git a/README.md b/README.md index a01050e..27e203c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,24 @@ NeoVim Setup files =============== -This is my NeoVim setup with Vim-Plug and plugins : - - * Base16 themes - * Syntastic plugin - * NerdTree plugin - * Vim-Airline +This is mys neovim configuration with lua and paq plugins manager ## Installation +This Nvim installation need somes dependencies: + + * gcc (Tree-Sitter) + * g++ (Tree-Sitter) + * clang (Tree-sitter) + +For install plugins, you need to execute neovim with arguments like below + +``` +nvim --headless -u NONE -c 'lua require("plugins").bootstrap_paq()' +``` + This repository is installable with [dotinstall][l_dotinstall] : ``` -dotinstall https://git.epha.se/ephase/vim.git +dotinstall https://git.epha.se/ephase/dotinstall.git ``` diff --git a/conf/nvim/lua/keybiding.lua b/conf/nvim/lua/keybiding.lua index 7d0b87e..2b89fa2 100644 --- a/conf/nvim/lua/keybiding.lua +++ b/conf/nvim/lua/keybiding.lua @@ -1,8 +1,5 @@ - -- " 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} @@ -16,17 +13,19 @@ 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} ) + +-- git sign +-- Actions +local opts = { noremap = true, silent = true} +--vim.api.nvim_set_keymap('n', 'gp', require("gitsigns").preview_hunk, opts) +vim.api.nvim_set_keymap('n', 'gn', [[lua require('gitsigns').next_hunk()]], opts) +vim.api.nvim_set_keymap('n', 'gN', [[lua require('gitsigns').prev_hunk()]], opts) +vim.api.nvim_set_keymap('n', 'gs', ':Gitsigns stage_hunk', opts) +vim.api.nvim_set_keymap('n', 'gr', ':Gitsigns reset_hunk', opts) +vim.api.nvim_set_keymap('n', 'gd', [[lua require("gitsigns").diffthis('~')]], opts) diff --git a/conf/nvim/lua/plugins-options.lua b/conf/nvim/lua/plugins-options.lua index 75c6038..637773a 100644 --- a/conf/nvim/lua/plugins-options.lua +++ b/conf/nvim/lua/plugins-options.lua @@ -1,30 +1,12 @@ -- 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 - --- Tree sitter -local ts = require 'nvim-treesitter.configs' -ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} +require('plugins.treesitter') +require('plugins.lsp') +require('plugins.cmp') +require('plugins.gitsigns') +require('plugins.lualine') diff --git a/conf/nvim/lua/plugins.lua b/conf/nvim/lua/plugins.lua index 251ab1d..a5c483b 100644 --- a/conf/nvim/lua/plugins.lua +++ b/conf/nvim/lua/plugins.lua @@ -1,28 +1,27 @@ ---Plugins -local paq = require("paq") -paq { +-- Plugins +require "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'; + + -- status bar + 'nvim-lualine/lualine.nvim'; + -- Base16 theme - 'chriskempson/base16-vim'; + 'RRethy/nvim-base16'; -- NERDTree file manager 'scrooloose/nerdtree'; + 'lewis6991/gitsigns.nvim'; - -- 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'; -- need to install g++ package on Debian -- for tree sitter plugins - 'nvim-treesitter/nvim-treesitter' + 'nvim-treesitter/nvim-treesitter'; + + -- LSP installer + 'neovim/nvim-lspconfig'; + 'williamboman/nvim-lsp-installer'; + + -- autocompletion plugin + 'hrsh7th/nvim-cmp'; + 'hrsh7th/cmp-nvim-lsp' } diff --git a/conf/nvim/lua/plugins/cmp.lua b/conf/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..7159ef0 --- /dev/null +++ b/conf/nvim/lua/plugins/cmp.lua @@ -0,0 +1,37 @@ +-- Add additional capabilities supported by nvim-cmp +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) + +-- nvim-cmp setup +local cmp = require 'cmp' +cmp.setup { + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, + [''] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, + }, + sources = { + { name = 'nvim_lsp' }, + }, +} diff --git a/conf/nvim/lua/plugins/gitsigns.lua b/conf/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..7253a57 --- /dev/null +++ b/conf/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,3 @@ +require('gitsigns').setup { + keymaps = {}, -- NO default keybindings +} diff --git a/conf/nvim/lua/plugins/lsp.lua b/conf/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..27c9b9a --- /dev/null +++ b/conf/nvim/lua/plugins/lsp.lua @@ -0,0 +1,23 @@ +local lspconfig = require('lspconfig') + +-- lsp installet +-- +local lsp_installer = require("nvim-lsp-installer") + +-- Register a handler that will be called for each installed server when it's +-- ready (i.e. when installation is finished +-- or if the server is already installed). +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + -- This setup() function will take the provided server configuration and + -- decorate it with the necessary properties before passing it onwards to + -- lspconfig Refer to : + -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(opts) +end) diff --git a/conf/nvim/lua/plugins/lualine.lua b/conf/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..186a972 --- /dev/null +++ b/conf/nvim/lua/plugins/lualine.lua @@ -0,0 +1,29 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'base16', + component_separators = { left = '|', right = '|'}, + section_separators = { left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = false, + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} +} diff --git a/conf/nvim/lua/plugins/treesitter.lua b/conf/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..a55e428 --- /dev/null +++ b/conf/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,12 @@ +-- Tree sitter +local ts = require 'nvim-treesitter.configs' + +ts.setup { + ensure_installed = 'maintained', + sync_install = false, + ignore_install = { 'erlang' }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + } +} diff --git a/conf/nvim/lua/settings.lua b/conf/nvim/lua/settings.lua index 97ebb92..8778856 100644 --- a/conf/nvim/lua/settings.lua +++ b/conf/nvim/lua/settings.lua @@ -34,10 +34,20 @@ vim.cmd('colorscheme base16-classic-dark') vim.cmd('au BufWinLeave *.* mkview') vim.cmd('au BufWinEnter *.* silent! loadview') --- inoremap pumvisible()? "\" : "\" --- inoremap pumvisible()? "\" : "\" +-- Diagnostic settings +-- +-- diagnostic windows must be float +vim.diagnostic.config { + virtual_text = false, + signs = false, + underline = true, +} +-- You will likely want to reduce updatetime which affects CursorHold +-- note: this setting is global and should be set only once +vim.o.updatetime = 250 +vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] -- Autotype vim.cmd('au BufRead,BufNewFile *.md setlocal textwidth=80')