Solved Noob question regarding neovim

I'm learning neovim, add find it a fantastic editor with completions.
Here i'm posting my init.vim file:
...

I just wonder how to select multiple lines to copy paste.
Thanks
 
Last edited:
With vim you use shift-v to select multiple lines (ctrl-v allows you to select a 'block' of text). Don't know if it's the same for neovim though.
 
I found something , it goes like this,
V: - start visual mode linewise (shift-v)
move cursor
y: - yank
p: - put text after cursor below
(P : - put text after cursor above)
 
Configuring neovim-qt is a form of "dark-art",
Here i'm posting my current ~/.config/nvim/init.vim for who would be interested:

Code:
"SET--------------------------------------------------------------------
set number
set autoindent
set tabstop=4
set shiftwidth=4
set smarttab
set softtabstop=4
set mouse=a
set encoding=UTF-8
set rtp^="/usr/home/x/.opam/4.11.2/share/ocp-indent/vim"
set hidden
" suppress the annoying 'match x of y', 'The only match' and 'Pattern not found' messages
set shortmess+=c
set cursorline
set title
set wrap
set encoding=utf-8
set linebreak
set completeopt=noinsert,menuone,noselect
colorscheme desert

"LET-------------------------------------------------------------------
let g:LanguageClient_serverCommands = {'ocaml': ['ocamllsp'] , 'crystal': ['crystalline'] , 'racket': ['racket -l racket-langserver'] }
"integrate ocaml,opam,neovim,python,pynvim,merlin
let g:sql_type_default = 'pgsql'
let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"
"nvim select multiline
let g:sml#echo_yank_str = 1
let g:mapleader="\<Space>"

let g:ale_sign_error                  = '✘'
let g:ale_sign_warning                = '⚠'
highlight ALEErrorSign ctermbg        =NONE ctermfg=red
highlight ALEWarningSign ctermbg      =NONE ctermfg=yellow
"You then enable ALE only for languages that you're not using language servers for.
let g:ale_linters_explicit            = 1
let g:ale_lint_on_text_changed        = 'never'
let g:ale_lint_on_enter               = 0
let g:ale_lint_on_save                = 1
let g:ale_fix_on_save                 = 1
let g:ale_linters = { 'ocaml': ['merlin']}
let g:ale_fixers = { 'ocaml': ['ocamlformat'], '*': ['remove_trailing_lines', 'trim_whitespace']}

" Configuration example
let g:floaterm_keymap_new    = '<F7>'
let g:floaterm_keymap_prev   = '<F8>'
let g:floaterm_keymap_next   = '<F9>'
let g:floaterm_keymap_toggle = '<F12>'
let g:floaterm_keymap_new = '<Leader>ft'

"AUTOCMD---------------------------------------------------------------------
" Start NERDTree and put the cursor back in the other window.
autocmd VimEnter * NERDTree | wincmd p
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd User FloatermOpen        " triggered after opening a new/existed floaterm
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()

"MAP----------------------------------------------------------------------------------------
nmap     <F8> :TagbarToggle<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-l> :call CocActionAsync('jumpDefinition')<CR>
"nvim select multiline
nnoremap <Space>v :call sml#mode_on()<CR>


nnoremap <F5>          :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K    :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd   :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>


" When the <Enter> key is pressed while the popup menu is visible, it only hides the menu.
"Use this mapping to close the menu and also start a new line.
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

nnoremap   <silent>   <F7>    :FloatermNew<CR>
tnoremap   <silent>   <F7>    <C-\><C-n>:FloatermNew<CR>
nnoremap   <silent>   <F8>    :FloatermPrev<CR>
tnoremap   <silent>   <F8>    <C-\><C-n>:FloatermPrev<CR>
nnoremap   <silent>   <F9>    :FloatermNext<CR>
tnoremap   <silent>   <F9>    <C-\><C-n>:FloatermNext<CR>
nnoremap   <silent>   <F12>   :FloatermToggle<CR>
tnoremap   <silent>   <F12>   <C-\><C-n>:FloatermToggle<CR>

"vim-plug section , a minimalist vim plugin manager
call plug#begin()
"LSP-CLIENT-------------------------------------------------------------
"conquer of completion ,cfr vscode
Plug 'neoclide/coc.nvim'
"Language Server Protocol support for vim and neovim.
Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }
"ALE Asynchronous Lint Engine is a plugin providing linting syntax checking and semantic errors
"and acts as a Vim Language Server Protocol client.
"Used for ocaml
Plug 'dense-analysis/ale'
"assuming you're using vim-plug: https://github.com/junegunn/vim-plug

"LANGUAGES-------------------------------------------------------------

"Clojure support
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

"This plugin adds Go language support for Vim
Plug 'fatih/vim-go'
"An autocompletion daemon for the Go programming language
Plug 'nsf/gocode'

"crystal
Plug 'elbywan/crystalline'


"zig
Plug 'zigtools/zls'

"syntax highlighting and auto-completion support for PostgreSQL
Plug 'https://github.com/lifepillar/pgsql.vim.git'
"Functions/mappings/commands to enable Vim to access several databases
Plug 'vim-scripts/dbext.vim'

" CSS Color Preview
Plug 'https://github.com/ap/vim-css-color'

"coc-plug nginx
Plug 'yaegassy/coc-nginx', {'do': 'yarn install --frozen-lockfile'}

"GUI-------------------------------------------------------------------
"The NERDTree is a file system explorer for the Vim editor
Plug 'https://github.com/preservim/nerdtree.git'

"Terminal
Plug 'voldikss/vim-floaterm'


"Browse GitHub events (user dashboard, user/repo activity) in Vim.
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

"Lean & mean status/tabline for vim that's light as air.
Plug 'https://github.com/vim-airline/vim-airline.git'


Plug 'kyazdani42/nvim-web-devicons'


"Add-icons
Plug 'ryanoasis/vim-devicons'

"Terminal-line
Plug 'tc50cal/vim-terminal'

"EDITOR----------------------------------------------------------------

"A simple, easy-to-use Vim alignment plugin.
Plug 'junegunn/vim-easy-align'

"UltiSnips is the ultimate solution for snippets in Vim
"vim-snippets, This repository contains snippets files for various programming languages.
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

"Collection of awesome color schemes for Vim, merged for quick use.
Plug 'https://github.com/rafi/awesome-vim-colorschemes'

"This is a script which generates a list of compiler flags from a project with an arbitrary build system.
Plug 'rdnetto/YCM-Generator'

"fzf is a general-purpose command-line fuzzy finder.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

"a class outline viewer for Vim
Plug 'majutsushi/tagbar'

"Yank lines not adjacent
Plug 'Rasukarusan/nvim-select-multi-line'

"Comment stuff out.
Plug 'tpope/vim-commentary'

"nvim-notify
Plug 'rcarriga/nvim-notify'

"function-signatures
Plug 'ray-x/lsp_signature.nvim'

"shows a git diff in the sign column
Plug 'airblade/vim-gitgutter'

"Super fast git decorations implemented purely in lua/teal.
Plug 'lewis6991/gitsigns.nvim'

"Plugin----------------------------------------------------------------
"nvim-completion-manager
Plug 'ncm2/ncm2'
"Yet Another Remote Plugin Framework for Neovim
Plug 'roxma/nvim-yarp'
" NOTE: you need to install completion sources to get completions. Check our wiki page for a list of sources: https://github.com/ncm2/ncm2/wiki
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
"DISABLED PLUGINS
"Barbar
"Plug 'romgrk/barbar.nvim'
"A neovim plugin to persist and toggle multiple terminals during an editing session
"Plug 'akinsho/toggleterm.nvim'
"COC-ALTERNATIVES DISABLED---------------------------------------------------
"A super simple, super minimal, super light-weight tab-completion plugin for Vim.
"Plug 'ajh17/VimCompletesMe'
"extensible and asynchronous completion framework for neovim
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Supertab is a vim plugin which allows you to use <Tab> for all your insert completion needs (:help ins-completion).
"https://github.com/ervandew/supertab
call plug#end()
 
The real fun in configuring neovim is by using its Lua configuration: ~/.config/nvim/init.lua

Code:
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
end

local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })

require("packer").startup(function()
    use "wbthomason/packer.nvim"

    use "airblade/vim-gitgutter"
    use "NLKNguyen/papercolor-theme"

    use "hrsh7th/cmp-nvim-lsp"
    use "hrsh7th/nvim-cmp"
    use "neovim/nvim-lspconfig"
    use "onsails/lspkind-nvim"
    use "quangnguyen30192/cmp-nvim-ultisnipsips"
    use "williamboman/nvim-lsp-installer"
end)

local lspconfig = require("lspconfig")
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)

local servers = { "pylsp" }
for _, lsp in ipairs(servers) do
    lspconfig[lsp].setup {
        capabilities = capabilities
    }
end

-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
    mapping = cmp.mapping.preset.insert({
        ['<C-d>'] = cmp.mapping.scroll_docs(-4),
        ['<C-f>'] = cmp.mapping.scroll_docs(4),
        ['<C-Space>'] = cmp.mapping.complete(),
        ['<CR>'] = cmp.mapping.confirm {
        behavior = cmp.ConfirmBehavior.Replace,
        select = true,
        },
        ['<Tab>'] = cmp.mapping(function(fallback)
        if cmp.visible() then
            cmp.select_next_item()
        else
            fallback()
        end
        end, { 'i', 's' }),
        ['<S-Tab>'] = cmp.mapping(function(fallback)
        if cmp.visible() then
            cmp.select_prev_item()
        else
            fallback()
        end
        end, { 'i', 's' }),
    }),
    sources = {
        { name = 'nvim_lsp' },
    },
}

--HOME = os.getenv("HOME")

vim.o.encoding = "utf-8"
vim.o.ffs = "unix,dos,mac"

vim.o.autoread = true
vim.o.background = "dark"
vim.o.list = true

vim.o.hidden = true

vim.o.mouse = "a"

vim.o.autoindent = true
vim.o.breakindent = true
vim.o.smartindent = true

vim.o.expandtab = true
vim.o.shiftround = true
vim.o.shiftwidth = 4

vim.o.wrap = false

vim.o.swapfile = false
vim.o.backup = false
vim.o.writebackup = false

vim.o.cmdheight = 2

vim.o.updatetime = 250

vim.wo.number = true
vim.o.relativenumber = false
vim.o.cursorline = true
vim.o.ruler = true
vim.o.scrolloff = 4
vim.o.sidescrolloff = 4

vim.o.hlsearch = true
vim.o.incsearch = true
vim.o.ignorecase = true
vim.o.smartcase = true

vim.o.completeopt = "menuone,noinsert,noselect"
vim.o.wildmode = "list,longest"
vim.o.termguicolors = true

vim.o.showcmd = true
vim.o.showmode = true
vim.o.showmatch = true

vim.o.errorbells = false
vim.o.visualbell = false

vim.g.mapleader = ","

vim.api.nvim_set_keymap(
    "n",
    "<leader>w",
    ":w!<CR>",
    { noremap = false }
)
vim.api.nvim_set_keymap(
    "n",
    "<leader>/",
    ":noh<CR>",
    { noremap = true, silent = true }
)
vim.api.nvim_set_keymap(
    "n",
    "<S-u>",
    ":redo<CR>",
    { noremap = false }
)

P.S.: My preference for Lua configuration is purely subjective. Vimscript or not, we're all Vim users (except for the others ?) by the end of the day!
 
Back
Top