Add neovim config
This commit is contained in:
parent
84cede1a28
commit
62999295f7
143
.config/nvim/init.vim
Executable file
143
.config/nvim/init.vim
Executable file
|
@ -0,0 +1,143 @@
|
|||
" basic vim settings (tabs, line numbers, etc.)
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set showtabline=2
|
||||
set mouse=a
|
||||
set number
|
||||
set expandtab
|
||||
set cursorline
|
||||
|
||||
" plugins
|
||||
call plug#begin()
|
||||
Plug 'sainnhe/sonokai'
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'preservim/nerdtree'
|
||||
Plug 'vim-airline/vim-airline'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'saadparwaiz1/cmp_luasnip'
|
||||
Plug 'L3MON4D3/LuaSnip'
|
||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||
call plug#end()
|
||||
|
||||
" color fix
|
||||
if has('termguicolors')
|
||||
set termguicolors
|
||||
endif
|
||||
|
||||
" sonokai theme configuration
|
||||
let g:sonokai_style = 'shusia'
|
||||
let g:sonokai_enable_italic = 0
|
||||
let g:sonokai_disable_italic_comment = 1
|
||||
colorscheme sonokai
|
||||
|
||||
" tabs
|
||||
map <C-z> :tabp<CR>
|
||||
map <C-x> :tabn<CR>
|
||||
map <C-c> :tabnew<CR>
|
||||
|
||||
" save/quit
|
||||
command Dw :w !doas dd of=%
|
||||
nnoremap <C-s> :w<CR>
|
||||
nnoremap <C-q> :q<CR>
|
||||
|
||||
" NERDTree
|
||||
nnoremap <C-t> :NERDTreeToggle<CR>
|
||||
let g:NERDTreeAutoDeleteBuffer = 1
|
||||
let g:NERDTreeMinimalUI = 1
|
||||
let g:NERDTreeQuitOnOpen = 1
|
||||
let g:NERDTreeDirArrowExpandable = '>'
|
||||
let g:NERDTreeDirArrowCollapsible = '<'
|
||||
|
||||
" LSP stuff
|
||||
lua << EOF
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
local opts = { noremap=true, silent=true }
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
end
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
nvim_lsp.clangd.setup {
|
||||
on_attach = on_attach;
|
||||
capabilities = capabilities;
|
||||
}
|
||||
nvim_lsp.rust_analyzer.setup {
|
||||
on_attach = on_attach;
|
||||
capabilities = capabilities;
|
||||
}
|
||||
|
||||
vim.o.completeopt = 'menuone,noselect'
|
||||
local luasnip = require 'luasnip'
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
}
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = { "c", "toml" },
|
||||
highlight = {
|
||||
enable = true,
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
@ -26,8 +26,8 @@ static const int vertpadtab = 33;
|
|||
static const int horizpadtabi = 15;
|
||||
static const int horizpadtabo = 15;
|
||||
static const int scalepreview = 4;
|
||||
static const char *fonts[] = {"Cozette:style:medium:size=12"};
|
||||
static const char dmenufont[] = "Cozette:style:medium:size=12";
|
||||
static const char *fonts[] = {"Cozette:style:medium:size=10"};
|
||||
static const char dmenufont[] = "Cozette:style:medium:size=10";
|
||||
static const int colorfultag = 1; /* 0 means use SchemeSel for selected non-vacant tag */
|
||||
|
||||
// theme
|
||||
|
|
Reference in a new issue