neovim config is now in lua
This commit is contained in:
parent
0b5fac6216
commit
24661bf28a
9 changed files with 262 additions and 150 deletions
|
@ -9,8 +9,8 @@ color = 000000 ffff00
|
||||||
foreground = b2b2b2
|
foreground = b2b2b2
|
||||||
background = 080808
|
background = 080808
|
||||||
|
|
||||||
# selection-foreground = 080808
|
selection-foreground = 080808
|
||||||
# selection-background = b2ceee
|
selection-background = b2ceee
|
||||||
|
|
||||||
regular0 = 323437
|
regular0 = 323437
|
||||||
regular1 = ff5454
|
regular1 = ff5454
|
||||||
|
|
1
nvim.lua/.config/nvim/.gitignore
vendored
Normal file
1
nvim.lua/.config/nvim/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
plugin
|
|
@ -1,80 +1,86 @@
|
||||||
require'plugins'
|
-- set leader and locleader before setting any maps
|
||||||
|
vim.g.mapleader = ' '
|
||||||
|
vim.g.maplocalleader = '\\'
|
||||||
|
|
||||||
|
-- set up packer and all the plugins
|
||||||
|
require('plugins')
|
||||||
|
|
||||||
|
-- old config still to luaify
|
||||||
|
vim.cmd([[
|
||||||
|
" filetype magic
|
||||||
|
autocmd BufRead,BufNewFile *.nasm set filetype=nasm
|
||||||
|
|
||||||
|
" langmap russian
|
||||||
|
set langmap=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz
|
||||||
|
|
||||||
|
" Incrementally show effects of :s, :smagic, :snomagic
|
||||||
|
set icm=split
|
||||||
|
"set signcolumn=yes
|
||||||
|
|
||||||
|
set number
|
||||||
|
|
||||||
|
|
||||||
|
set nobackup nowritebackup
|
||||||
|
set noswapfile
|
||||||
|
|
||||||
-- LSP
|
" autosmartident
|
||||||
-- nix
|
set ai
|
||||||
if vim.fn.executable('rnix-lsp') == 1 then
|
set si
|
||||||
require'lspconfig'.rnix.setup{
|
set tabstop=4
|
||||||
autostart = false,
|
set shiftwidth=4
|
||||||
}
|
set softtabstop=4
|
||||||
end
|
set expandtab
|
||||||
|
|
||||||
-- Rust
|
" arrows for visual line navigation
|
||||||
if vim.fn.executable('rust-analyzer') == 1 then
|
imap <up> <C-O>gk
|
||||||
local rt = require'rust-tools'
|
imap <down> <C-O>gj
|
||||||
|
nmap <up> gk
|
||||||
|
nmap <down> gj
|
||||||
|
vmap <up> gk
|
||||||
|
vmap <down> gj
|
||||||
|
|
||||||
rt.setup({
|
set history=999
|
||||||
tools = {
|
set undolevels=999
|
||||||
inlay_hints = {
|
|
||||||
auto = true,
|
|
||||||
only_current_line = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
server = {
|
|
||||||
autostart = false,
|
|
||||||
on_attach = function(_, bufnr)
|
|
||||||
vim.keymap.set("n", "<Leader>h", rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
||||||
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
|
" Copy to clipboard
|
||||||
|
vnoremap <leader>y "+y
|
||||||
|
nnoremap <leader>Y "+yg_
|
||||||
|
nnoremap <leader>y "+y
|
||||||
|
nnoremap <leader>yy "+yy
|
||||||
|
" Paste from clipboard
|
||||||
|
nnoremap <leader>p "+p
|
||||||
|
nnoremap <leader>P "+P
|
||||||
|
vnoremap <leader>p "+p
|
||||||
|
vnoremap <leader>P "+P
|
||||||
|
|
||||||
end
|
"set updatetime=107
|
||||||
|
|
||||||
|
" disable modelines
|
||||||
|
set nomodeline
|
||||||
|
|
||||||
-- require'completion'
|
" change tab completion to more bash-like
|
||||||
local cmp = require'cmp'
|
set wildmode=longest:full,list:full
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require'snippy'.expand_snippet(args.body)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
" U is quite useless
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
nnoremap U :echo "NOPE!"<CR>
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
|
||||||
['<Tab>'] = cmp.mapping.confirm({
|
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
|
||||||
select = true,
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
|
|
||||||
sources = cmp.config.sources({
|
" help is quite annoying when you miss esc
|
||||||
{ name = 'nvim_lsp' },
|
map <F1> <Esc>
|
||||||
{ name = 'snippy' }, -- For snippy users.
|
imap <F1> <Esc>
|
||||||
{ name = 'buffer' },
|
|
||||||
{ name = 'path' },
|
|
||||||
{ name = 'nvim_lua' },
|
|
||||||
}),
|
|
||||||
|
|
||||||
formatting = {
|
" do not conceal stuff
|
||||||
format = function(entry, vim_item)
|
set conceallevel=0
|
||||||
vim_item.kind = string.format('%s', vim_item.kind)
|
set foldlevel=999
|
||||||
vim_item.menu = ({
|
|
||||||
nvim_lsp = '[LSP]',
|
|
||||||
buffer = '[B]',
|
|
||||||
path = '[F]',
|
|
||||||
snippy = '[S]',
|
|
||||||
nvim_lua = '[vim]',
|
|
||||||
})[entry.source.name]
|
|
||||||
|
|
||||||
return vim_item
|
" Whitespace highlight
|
||||||
end,
|
highlight RedundantSpaces ctermbg=red guibg=red
|
||||||
}
|
match RedundantSpaces /\s\+\%#\@<!$/
|
||||||
})
|
|
||||||
|
" highlight yanked text
|
||||||
|
augroup highlight_yank
|
||||||
|
autocmd!
|
||||||
|
au TextYankPost * silent! lua vim.highlight.on_yank { higroup='IncSearch', timeout=200 }
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
-- nvim cmp
|
-- nvim cmp
|
||||||
|
|
||||||
return require'cmp'.setup({
|
-- setup completion menu
|
||||||
|
vim.cmd([[
|
||||||
|
set completeopt=menu,menuone,noselect
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- setup cmp proper: pretty much default config
|
||||||
|
local cmp = require'cmp'
|
||||||
|
return cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require'snippy'.expand_snippet(args.body)
|
require'snippy'.expand_snippet(args.body)
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
@ -12,7 +19,7 @@ return require'cmp'.setup({
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<Tab>'] = cmp.mapping.confirm({
|
['<CR>'] = cmp.mapping.confirm({
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
select = true,
|
select = true,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
require'lspconfig'.rnix.setup{
|
|
||||||
autostart = false,
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
-- nvim_lsp object
|
|
||||||
local nvim_lsp = require'lspconfig'
|
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
||||||
|
|
||||||
-- Enable rust_analyzer
|
|
||||||
nvim_lsp.rust_analyzer.setup({
|
|
||||||
autostart=false,
|
|
||||||
capabilities=capabilities,
|
|
||||||
-- on_attach is a callback called when the language server attachs to the buffer
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
-- to enable rust-analyzer settings visit:
|
|
||||||
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
|
|
||||||
["rust-analyzer"] = {
|
|
||||||
-- enable clippy diagnostics on save
|
|
||||||
checkOnSave = {
|
|
||||||
command = "clippy"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Enable diagnostics
|
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
||||||
virtual_text = false,
|
|
||||||
signs = true,
|
|
||||||
update_in_insert = true,
|
|
||||||
}
|
|
||||||
)
|
|
66
nvim.lua/.config/nvim/lua/lsp_setup.lua
Normal file
66
nvim.lua/.config/nvim/lua/lsp_setup.lua
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
local nvim_lsp = require'lspconfig'
|
||||||
|
local cmp_lsp = require'cmp_nvim_lsp'
|
||||||
|
|
||||||
|
-- General LSP config
|
||||||
|
-- Limit capabilities to advertised by cmp
|
||||||
|
local capabilities = cmp_lsp.default_capabilities()
|
||||||
|
|
||||||
|
-- default lsp config
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
-- Use an on_attach function to only map the following keys
|
||||||
|
-- after the language server attaches to the current buffer
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local lsp_flags = {
|
||||||
|
-- This is the default in Nvim 0.7+
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
|
-- always show sign column
|
||||||
|
vim.cmd([[set signcolumn=yes]])
|
||||||
|
|
||||||
|
-- Setting up servers per language
|
||||||
|
-- Nix
|
||||||
|
nvim_lsp['rnix'].setup{
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Rust: using rust tools package
|
||||||
|
local rt = require("rust-tools")
|
||||||
|
rt.setup({
|
||||||
|
server = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
capabilities = capabilities,
|
||||||
|
},
|
||||||
|
})
|
11
nvim.lua/.config/nvim/lua/lualine_setup.lua
Normal file
11
nvim.lua/.config/nvim/lua/lualine_setup.lua
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
-- this now handled by the lualine
|
||||||
|
vim.cmd([[set noshowmode]])
|
||||||
|
|
||||||
|
return require('lualine').setup {
|
||||||
|
options = {
|
||||||
|
icons_enabled = true,
|
||||||
|
theme = 'moonfly',
|
||||||
|
-- section_separators = '',
|
||||||
|
-- component_seaparators = '',
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,59 +1,115 @@
|
||||||
local ensure_packer = function()
|
local ensure_packer = function()
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||||
if fn.empty(fn.glob(install_path)) > 0 then
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
||||||
vim.cmd [[packadd packer.nvim]]
|
vim.cmd [[packadd packer.nvim]]
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local setup_fzf = function()
|
||||||
|
vim.api.nvim_set_keymap('n', '<c-P>', "<cmd>lua require('fzf-lua').files()<CR>", { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>f', "<cmd>lua require('fzf-lua').git_files()<CR>", { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>b', "<cmd>lua require('fzf-lua').buffers()<CR>", { noremap = true, silent = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
local packer_bootstrap = ensure_packer()
|
local packer_bootstrap = ensure_packer()
|
||||||
|
|
||||||
return require('packer').startup(function(use)
|
return require('packer').startup(function(use)
|
||||||
use 'wbthomason/packer.nvim'
|
use 'wbthomason/packer.nvim'
|
||||||
|
|
||||||
-- insert images into markdown automagically
|
-- insert images into markdown automagically
|
||||||
use 'ferrine/md-img-paste.vim'
|
use {
|
||||||
|
'ferrine/md-img-paste.vim',
|
||||||
|
ft = { 'markdown' },
|
||||||
|
config = vim.cmd([[
|
||||||
|
" insert images into markdown automagically
|
||||||
|
autocmd FileType markdown nmap <buffer><silent> <localleader>p :call mdip#MarkdownClipboardImage()<CR>
|
||||||
|
let g:mdip_imgdir = 'static'
|
||||||
|
let g:mdip_imgname = 'image'
|
||||||
|
]])
|
||||||
|
}
|
||||||
|
|
||||||
--Better syntax
|
--Better syntax
|
||||||
use 'rust-lang/rust.vim'
|
use 'rust-lang/rust.vim'
|
||||||
use 'LnL7/vim-nix'
|
use 'LnL7/vim-nix'
|
||||||
use 'cespare/vim-toml'
|
use 'cespare/vim-toml'
|
||||||
use 'JuliaEditorSupport/julia-vim'
|
use 'JuliaEditorSupport/julia-vim'
|
||||||
use 'lervag/vimtex'
|
use {
|
||||||
use 'lepture/vim-jinja'
|
'lervag/vimtex',
|
||||||
use 'neomutt/neomutt.vim'
|
ft = { 'tex' },
|
||||||
use 'godlygeek/tabular'
|
-- do not conceal stuff
|
||||||
use 'preservim/vim-markdown'
|
config = vim.cmd([[ let g:tex_conceal = '' ]]),
|
||||||
|
}
|
||||||
|
use 'lepture/vim-jinja'
|
||||||
|
use 'neomutt/neomutt.vim'
|
||||||
|
use 'godlygeek/tabular'
|
||||||
|
use 'preservim/vim-markdown'
|
||||||
|
|
||||||
-- pretty bits
|
-- pretty bits
|
||||||
use 'bluz71/vim-moonfly-colors'
|
use {
|
||||||
use 'vim-airline/vim-airline'
|
'bluz71/vim-moonfly-colors',
|
||||||
|
config = vim.cmd([[ set termguicolors
|
||||||
|
colorscheme moonfly ]]),
|
||||||
|
}
|
||||||
|
use {
|
||||||
|
'nvim-lualine/lualine.nvim',
|
||||||
|
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
||||||
|
config = function()
|
||||||
|
require('lualine_setup')
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
-- neovim VSCode edition
|
-- Git
|
||||||
use 'neovim/nvim-lspconfig'
|
use 'tpope/vim-fugitive'
|
||||||
use 'simrat39/rust-tools.nvim'
|
|
||||||
-- completion
|
|
||||||
use 'hrsh7th/nvim-cmp'
|
|
||||||
use 'hrsh7th/cmp-nvim-lsp'
|
|
||||||
use 'hrsh7th/cmp-buffer'
|
|
||||||
use 'hrsh7th/cmp-path'
|
|
||||||
use 'hrsh7th/cmp-nvim-lua'
|
|
||||||
-- just because cmp requires snippet
|
|
||||||
use 'dcampos/nvim-snippy'
|
|
||||||
use 'dcampos/cmp-snippy'
|
|
||||||
|
|
||||||
-- navigating files
|
-- Nifty stuff
|
||||||
use 'junegunn/fzf'
|
use 'tpope/vim-surround'
|
||||||
use 'junegunn/fzf.vim'
|
use {
|
||||||
|
'ibhagwan/fzf-lua',
|
||||||
|
config = setup_fzf(),
|
||||||
|
}
|
||||||
|
|
||||||
-- Automatically set up your configuration after cloning packer.nvim
|
-- completion
|
||||||
-- Put this at the end after all plugins
|
use {
|
||||||
if packer_bootstrap then
|
'hrsh7th/nvim-cmp',
|
||||||
require('packer').sync()
|
requires = {
|
||||||
end
|
-- completion sources
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
'hrsh7th/cmp-buffer',
|
||||||
|
'hrsh7th/cmp-path',
|
||||||
|
'hrsh7th/cmp-nvim-lua',
|
||||||
|
-- snippets (hard requirement by cmp)
|
||||||
|
'dcampos/nvim-snippy',
|
||||||
|
'dcampos/cmp-snippy'
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('completion')
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- neovim VSCode edition
|
||||||
|
use {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
ft = {
|
||||||
|
'rust',
|
||||||
|
'nix',
|
||||||
|
-- 'python',
|
||||||
|
},
|
||||||
|
after = { 'nvim-cmp' },
|
||||||
|
requires = { 'simrat39/rust-tools.nvim' },
|
||||||
|
config = function()
|
||||||
|
require'lsp_setup'
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Automatically set up your configuration after cloning packer.nvim
|
||||||
|
-- Put this at the end after all plugins
|
||||||
|
if packer_bootstrap then
|
||||||
|
require('packer').sync()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue