Browse Source

splitting nvim config

master
Ivan Polyakov 2 years ago
parent
commit
ed271dd4c2
  1. 5
      .config/nvim/init.lua
  2. 121
      .config/nvim/init.vim
  3. 48
      .config/nvim/lua/init/gitsigns.lua
  4. 51
      .config/nvim/lua/init/lsp_and_cmp.lua
  5. 14
      .config/nvim/lua/init/plugins.lua
  6. 79
      .config/nvim/lua/plugins.lua
  7. 33
      .vim/init/general.vim
  8. 18
      .vim/init/vimtex.vim

5
.config/nvim/init.lua

@ -0,0 +1,5 @@
vim.cmd('source ~/.vim/init/general.vim')
require 'init.plugins'
require 'init.gitsigns'
require 'init.lsp_and_cmp'

121
.config/nvim/init.vim

@ -1,121 +0,0 @@
""" General
syntax enable
set nocompatible | filetype indent plugin on | syn on
set backspace=indent,eol,start
set ruler " show current line and column
set nu rnu " show line numbers
set cc=75 " show column ruler
set ts=4
set shiftwidth=4
set expandtab
set scrolloff=2
set completeopt=menu,menuone,noselect
""" Colors
syntax on
colorscheme nord " !nord plugin required
""" Finding files
set path+=** " Provides tab-completion for all file-related tasks
set wildmenu " Display all mathing files when we tab complete
""" Tags
command! Mktags !ctags -R .
""" file browsing
let g:netrw_banner=0 " disable annoying banner
let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
"" typo
setlocal spell
set spelllang=en
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
""" Plugins
lua require('plugins')
lua require('lualine').setup{}
"" Snippets
imap <expr> <Tab> snippy#can_expand_or_advance() ? '<Plug>(snippy-expand-or-advance)' : '<Tab>'
imap <expr> <S-Tab> snippy#can_jump(-1) ? '<Plug>(snippy-previous)' : '<S-Tab>'
smap <expr> <Tab> snippy#can_jump(1) ? '<Plug>(snippy-next)' : '<Tab>'
smap <expr> <S-Tab> snippy#can_jump(-1) ? '<Plug>(snippy-previous)' : '<S-Tab>'
xmap <Tab> <Plug>(snippy-cut-text)
"" LaTeX
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:vimtex_quickfix_mode=0
let g:vimtex_syntax_conceal = {
\ 'accents': 1,
\ 'cites': 1,
\ 'fancy': 1,
\ 'greek': 1,
\ 'math_bounds': 1,
\ 'math_delimiters': 1,
\ 'math_fracs': 1,
\ 'math_super_sub': 1,
\ 'math_symbols': 1,
\ 'sections': 1,
\ 'styles': 1,
\}
set conceallevel=2
lua << EOF
-- LSP and completions --
-- Completions --
local cmp = require('cmp')
cmp.setup({
completion = { autocomplete = false },
snippet = {
expand = function (args)
require('snippy').expand_snippet(args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'snippy' }
})
})
-- LSP --
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local lsp = require('lspconfig')
local capabilities = require('cmp_nvim_lsp')
.update_capabilities(vim.lsp.protocol.make_client_capabilities())
lsp.clangd.setup {
filetypes = { 'c', 'cpp', 'cxx' },
capabilities = capabilities
}
lsp.eslint.setup {
capabilities = capabilities
}
lsp.sumneko_lua.setup {
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
diagnostics = { globals = { 'vim' } },
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
},
telemetry = { enable = false },
},
},
capabilities = capabilities,
}
EOF

48
.config/nvim/lua/init/gitsigns.lua

@ -0,0 +1,48 @@
local status_ok, gitsigns = pcall(require, "gitsigns")
if not status_ok then
return
end
gitsigns.setup {
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
delete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
topdelete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
changedelete = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
interval = 1000,
follow_files = true,
},
attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
},
current_line_blame_formatter_opts = {
relative_time = false,
},
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000,
preview_config = {
-- Options passed to nvim_open_win
border = "single",
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
yadm = {
enable = false,
},
}

51
.config/nvim/lua/init/lsp_and_cmp.lua

@ -0,0 +1,51 @@
-- Completions --
local cmp = require('cmp')
cmp.setup({
completion = { autocomplete = false },
snippet = {
expand = function (args)
require('snippy').expand_snippet(args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'snippy' }
})
})
-- LSP --
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local lsp = require('lspconfig')
local capabilities = require('cmp_nvim_lsp')
.update_capabilities(vim.lsp.protocol.make_client_capabilities())
lsp.clangd.setup {
filetypes = { 'c', 'cpp', 'cxx' },
capabilities = capabilities
}
lsp.eslint.setup {
capabilities = capabilities
}
lsp.sumneko_lua.setup {
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
diagnostics = { globals = { 'vim' } },
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
},
telemetry = { enable = false },
},
},
capabilities = capabilities,
}

14
.config/nvim/lua/init/plugins.lua

@ -0,0 +1,14 @@
vim.cmd('colorscheme nord')
vim.cmd('source ~/.vim/init/vimtex.vim')
require 'plugins'
require 'lualine'.setup{}
vim.cmd [[
"" Snippets
imap <expr> <Tab> snippy#can_expand_or_advance() ? '<Plug>(snippy-expand-or-advance)' : '<Tab>'
imap <expr> <S-Tab> snippy#can_jump(-1) ? '<Plug>(snippy-previous)' : '<S-Tab>'
smap <expr> <Tab> snippy#can_jump(1) ? '<Plug>(snippy-next)' : '<Tab>'
smap <expr> <S-Tab> snippy#can_jump(-1) ? '<Plug>(snippy-previous)' : '<S-Tab>'
xmap <Tab> <Plug>(snippy-cut-text)
]]

79
.config/nvim/lua/plugins.lua

@ -1,39 +1,44 @@
return require('packer').startup(function() return require('packer').startup(function()
use 'wbthomason/packer.nvim' use 'wbthomason/packer.nvim'
-- Look and feel -- -- Look and feel --
use 'shaunsingh/nord.nvim' use 'shaunsingh/nord.nvim'
use { use {
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true } requires = { 'kyazdani42/nvim-web-devicons', opt = true }
} }
use 'preservim/nerdtree' use 'preservim/nerdtree'
use {
'nvim-treesitter/nvim-treesitter',
-- Snippets -- run = ':TSUpdate',
use 'dcampos/nvim-snippy' }
use 'honza/vim-snippets' use 'lewis6991/gitsigns.nvim'
-- Languages -- -- Snippets --
use { use 'dcampos/nvim-snippy'
'lervag/vimtex', use 'honza/vim-snippets'
tag = 'v2.9',
ft = 'tex'
} -- Languages --
use { use {
'digitaltoad/vim-pug', 'lervag/vimtex',
ft = {'pug', 'vue'} tag = 'v2.9',
} ft = 'tex'
}
use {
-- LSP and completions -- 'digitaltoad/vim-pug',
use 'neovim/nvim-lspconfig' ft = {'pug', 'vue'}
use 'hrsh7th/nvim-cmp' }
use 'hrsh7th/cmp-nvim-lsp'
use 'dcampos/cmp-snippy' -- Completions for snippets
-- LSP and completions --
use 'neovim/nvim-lspconfig'
-- Another tools -- use 'hrsh7th/nvim-cmp'
use 'MunifTanjim/nui.nvim' -- UI framework use 'hrsh7th/cmp-nvim-lsp'
use 'dcampos/cmp-snippy' -- Completions for snippets
-- Another tools --
use 'MunifTanjim/nui.nvim' -- UI framework
end) end)

33
.vim/init/general.vim

@ -0,0 +1,33 @@
""" General
syntax enable
set nocompatible | filetype indent plugin on | syn on
set backspace=indent,eol,start
set ruler " show current line and column
set nu rnu " show line numbers
set cc=75 " show column ruler
set ts=4
set shiftwidth=4
set expandtab
set scrolloff=2
set completeopt=menu,menuone,noselect
syntax on
""" Finding files
set path+=** " Provides tab-completion for all file-related tasks
set wildmenu " Display all mathing files when we tab complete
""" Tags
command! Mktags !ctags -R .
""" file browsing
let g:netrw_banner=0 " disable annoying banner
let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
"" typo
setlocal spell
set spelllang=en
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u

18
.vim/init/vimtex.vim

@ -0,0 +1,18 @@
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:vimtex_quickfix_mode=0
let g:vimtex_syntax_conceal = {
\ 'accents': 1,
\ 'cites': 1,
\ 'fancy': 1,
\ 'greek': 1,
\ 'math_bounds': 1,
\ 'math_delimiters': 1,
\ 'math_fracs': 1,
\ 'math_super_sub': 1,
\ 'math_symbols': 1,
\ 'sections': 1,
\ 'styles': 1,
\}
set conceallevel=2
let g:tex_conceal='abdmg'
Loading…
Cancel
Save