init.lua (#1)
* Switch neovim to init.lua from init.vim switch from coc to inbuilt nvim-lsp * Added completion with completion-nvim added most of the plugins from init.vim
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"rust-analyzer.server.path": "/usr/bin/rust-analyzer",
|
|
||||||
"coc.preferences.formatOnSaveFiletypes": ["css", "markdown", "rust", "json"],
|
|
||||||
"prettier.printWidth": 120
|
|
||||||
}
|
|
||||||
30
config/nvim/init.lua
Normal file
30
config/nvim/init.lua
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
require('plugins')
|
||||||
|
require('keymaps')
|
||||||
|
|
||||||
|
-- Need to replace this once lua api has vim modes
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
augroup Packer
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePost init.lua PackerCompile
|
||||||
|
autocmd BufWritePost plugins.lua PackerCompile
|
||||||
|
augroup end
|
||||||
|
]], false)
|
||||||
|
|
||||||
|
vim.o.timeoutlen = 700
|
||||||
|
vim.o.guifont='FiraCode Nerd Font Mono'
|
||||||
|
|
||||||
|
vim.o.undodir=vim.fn.stdpath('cache')..'/undodir'
|
||||||
|
vim.o.undofile = true
|
||||||
|
|
||||||
|
vim.o.showmode = false
|
||||||
|
vim.o.showtabline = 2
|
||||||
|
vim.o.autoindent = true
|
||||||
|
vim.o.tabstop=4
|
||||||
|
vim.o.shiftwidth=4
|
||||||
|
vim.o.expandtab = true
|
||||||
|
vim.o.hidden = true
|
||||||
|
vim.o.ignorecase = true
|
||||||
|
vim.o.smartcase = true
|
||||||
|
vim.o.termguicolors = true
|
||||||
|
-- No clue why window scoped
|
||||||
|
vim.wo.signcolumn='yes'
|
||||||
@@ -1,360 +0,0 @@
|
|||||||
"#################################################
|
|
||||||
"# Vim Plug
|
|
||||||
"##################################################
|
|
||||||
call plug#begin()
|
|
||||||
" QOL
|
|
||||||
Plug 'airblade/vim-rooter'
|
|
||||||
Plug 'yuttie/comfortable-motion.vim'
|
|
||||||
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
|
|
||||||
Plug 'folke/which-key.nvim'
|
|
||||||
Plug 'kdav5758/TrueZen.nvim'
|
|
||||||
Plug 'norcalli/nvim-colorizer.lua'
|
|
||||||
|
|
||||||
" Fzf
|
|
||||||
Plug 'junegunn/fzf'
|
|
||||||
Plug 'junegunn/fzf.vim'
|
|
||||||
|
|
||||||
" Statusline
|
|
||||||
Plug 'glepnir/galaxyline.nvim' , {'branch': 'main'}
|
|
||||||
" Tpope
|
|
||||||
Plug 'tpope/vim-surround'
|
|
||||||
Plug 'tpope/vim-vinegar'
|
|
||||||
Plug 'tpope/vim-repeat'
|
|
||||||
Plug 'tpope/vim-speeddating'
|
|
||||||
Plug 'tpope/vim-commentary'
|
|
||||||
Plug 'tpope/vim-fugitive'
|
|
||||||
" Rust
|
|
||||||
" Plug 'arzg/vim-rust-syntax-ext'
|
|
||||||
Plug 'rust-lang/rust.vim'
|
|
||||||
Plug 'mhinz/vim-crates'
|
|
||||||
Plug 'cespare/vim-toml'
|
|
||||||
" LSP
|
|
||||||
Plug 'onsails/lspkind-nvim'
|
|
||||||
Plug 'folke/lsp-trouble.nvim'
|
|
||||||
Plug 'neovim/nvim-lspconfig'
|
|
||||||
Plug 'nvim-lua/completion-nvim'
|
|
||||||
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
||||||
|
|
||||||
" Ctags
|
|
||||||
Plug 'ludovicchabant/vim-gutentags'
|
|
||||||
" Plug 'majutsushi/tagbar'
|
|
||||||
" GUI
|
|
||||||
" Plug 'uttarayan21/minimalist' " Plug 'dikiaap/minimalist'
|
|
||||||
Plug 'sainnhe/sonokai'
|
|
||||||
Plug 'kyazdani42/nvim-web-devicons'
|
|
||||||
Plug 'Yggdroot/indentLine'
|
|
||||||
" Text Objects
|
|
||||||
Plug 'wellle/targets.vim'
|
|
||||||
" Dictionary
|
|
||||||
Plug 'reedes/vim-wordy'
|
|
||||||
" Debug
|
|
||||||
Plug 'epheien/termdbg'
|
|
||||||
" Mail
|
|
||||||
Plug 'soywod/himalaya', {'rtp': 'vim'}
|
|
||||||
|
|
||||||
call plug#end()
|
|
||||||
|
|
||||||
"##################################################
|
|
||||||
"# Configurations
|
|
||||||
"##################################################
|
|
||||||
|
|
||||||
" set font
|
|
||||||
set guifont=FiraCode\ Nerd\ Font\ Mono
|
|
||||||
|
|
||||||
" Undo
|
|
||||||
set undodir=~/.cache/nvim/nvimdid
|
|
||||||
set undofile
|
|
||||||
|
|
||||||
set timeoutlen=300
|
|
||||||
|
|
||||||
" Numbers and tabs
|
|
||||||
set noshowmode
|
|
||||||
set showtabline=2
|
|
||||||
" set number relativenumber
|
|
||||||
set autoindent
|
|
||||||
set tabstop=4
|
|
||||||
set shiftwidth=4
|
|
||||||
set expandtab
|
|
||||||
set signcolumn=yes
|
|
||||||
set hidden
|
|
||||||
set ignorecase
|
|
||||||
set smartcase
|
|
||||||
set termguicolors
|
|
||||||
" set foldmethod=indent
|
|
||||||
" set cmdheight=2
|
|
||||||
|
|
||||||
nnoremap <silent> <F2> :set number! relativenumber! <CR>
|
|
||||||
nnoremap <silent> <F3> :IndentLinesToggle <CR>
|
|
||||||
|
|
||||||
inoremap <C-j> <ESC>
|
|
||||||
|
|
||||||
let mapleader = "\<Space>"
|
|
||||||
|
|
||||||
" BufferNext
|
|
||||||
nnoremap <Leader>q :bw <CR>
|
|
||||||
nnoremap <leader><leader> <c-^>
|
|
||||||
nnoremap <leader>n :bnext <CR>
|
|
||||||
nnoremap <leader>p :bprev <CR>
|
|
||||||
" Fzf
|
|
||||||
nnoremap <silent> <Leader>f :Files <CR>
|
|
||||||
nnoremap <silent> <Leader>; :Buffers <CR>
|
|
||||||
nnoremap <silent> <Leader>g :Rg <CR>
|
|
||||||
nnoremap <Leader>H :Himalaya <CR>
|
|
||||||
nnoremap <Leader>c "+y
|
|
||||||
nnoremap <Leader>v "+p
|
|
||||||
|
|
||||||
nnoremap <silent> <Leader>r :registers <CR>
|
|
||||||
nnoremap <F8> :Tags <CR>
|
|
||||||
nnoremap <silent> <Leader>z :call ZenToggle() <CR>
|
|
||||||
nnoremap <silent> <Leader>o :LspTroubleToggle <CR>
|
|
||||||
|
|
||||||
" Use <Tab> and <S-Tab> to navigate through popup menu
|
|
||||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
||||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
||||||
imap <tab> <Plug>(completion_smart_tab)
|
|
||||||
imap <s-tab> <Plug>(completion_smart_s_tab)
|
|
||||||
|
|
||||||
" Set completeopt to have a better completion experience
|
|
||||||
set completeopt=menuone,noinsert,noselect
|
|
||||||
|
|
||||||
" Avoid showing message extra message when using completion
|
|
||||||
set shortmess+=c
|
|
||||||
|
|
||||||
" Keymaps for lspconfig
|
|
||||||
|
|
||||||
" nnoremap gD :lua vim.lsp.buf.declaration()<CR>
|
|
||||||
" nnoremap <Leader>q, <cmd>lua vim.lsp.diagnostic.set_loclist()<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> gd :lua vim.lsp.buf.definition()<CR>
|
|
||||||
nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>, opts)
|
|
||||||
nnoremap <silent> gi :lua vim.lsp.buf.implementation() <CR>
|
|
||||||
nnoremap <silent> <C-k> :lua vim.lsp.buf.signature_help()<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <Leader>wa :lua vim.lsp.buf.add_workspace_folder()<CR>
|
|
||||||
nnoremap <silent> <Leader>wr :lua vim.lsp.buf.remove_workspace_folder()<CR>
|
|
||||||
nnoremap <silent> <Leader>wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <Leader>D :lua vim.lsp.buf.type_definition()<CR>
|
|
||||||
nnoremap <silent> <Leader>rn :lua vim.lsp.buf.rename()<CR>
|
|
||||||
nnoremap <silent> <Leader>ca :lua vim.lsp.buf.code_action()<CR>
|
|
||||||
nnoremap <silent> gr :lua vim.lsp.buf.references()<CR>, opts)
|
|
||||||
nnoremap <silent> <Leader>e :lua vim.lsp.diagnostic.show_line_diagnostics()<CR>
|
|
||||||
nnoremap <silent> [d :lua vim.lsp.diagnostic.goto_prev()<CR>, opts)
|
|
||||||
nnoremap <silent> ]d :lua vim.lsp.diagnostic.goto_next()<CR>, opts)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" Vim hardmode
|
|
||||||
inoremap <up> <nop>
|
|
||||||
inoremap <down> <nop>
|
|
||||||
inoremap <left> <nop>
|
|
||||||
inoremap <right> <nop>
|
|
||||||
nnoremap <up> <nop>
|
|
||||||
nnoremap <down> <nop>
|
|
||||||
nnoremap <left> <nop>
|
|
||||||
nnoremap <right> <nop>
|
|
||||||
|
|
||||||
" nnoremap <C-k> <C-]>
|
|
||||||
" nnoremap <C-l> <C-t>
|
|
||||||
|
|
||||||
" Disable help on F1
|
|
||||||
nnoremap <F1> <ESC>
|
|
||||||
inoremap <F1> <ESC>
|
|
||||||
|
|
||||||
" Ctags
|
|
||||||
let g:gutentags_cache_dir = expand('~/.cache/nvim/ctags/')
|
|
||||||
let g:gutentags_generate_on_new = 1
|
|
||||||
let g:gutentags_generate_on_missing = 1
|
|
||||||
let g:gutentags_generate_on_write = 1
|
|
||||||
let g:gutentags_generate_on_empty_buffer = 0
|
|
||||||
|
|
||||||
" Markdown Preview
|
|
||||||
" let g:mkdp_auto_start = 1
|
|
||||||
let g:mkdp_filetypes = ['markdown']
|
|
||||||
let g:indentLine_char = '▏'
|
|
||||||
let g:indentLine_concealcursor = 'inc'
|
|
||||||
let g:indentLine_conceallevel = 2
|
|
||||||
|
|
||||||
"A few more remaps
|
|
||||||
nnoremap <silent> <C-s> :source ~/.config/nvim/init.vim <CR>
|
|
||||||
nnoremap <silent> <Leader>m :call Mpcfzf() <CR>
|
|
||||||
|
|
||||||
|
|
||||||
" COC
|
|
||||||
" Use tab for trigger completion with characters ahead and navigate.
|
|
||||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
|
||||||
" other plugin before putting this into your config.
|
|
||||||
" inoremap <silent><expr> <TAB>
|
|
||||||
" \ pumvisible() ? "\<C-n>" :
|
|
||||||
" \ <SID>check_back_space() ? "\<TAB>" :
|
|
||||||
" \ coc#refresh()
|
|
||||||
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
|
||||||
" inoremap <expr><CR> pumvisible() ? "\<C-y>" : "\<CR>"
|
|
||||||
" inoremap <silent><expr> <c-space> coc#refresh()
|
|
||||||
" nnoremap <silent> K :call <SID>show_documentation()<CR>
|
|
||||||
" nnoremap <Leader>l :CocCommand <CR>
|
|
||||||
|
|
||||||
|
|
||||||
augroup AutoSaveGroup
|
|
||||||
autocmd!
|
|
||||||
" view files are about 500 bytes
|
|
||||||
" bufleave but not bufwinleave captures closing 2nd tab
|
|
||||||
" nested is needed by bufwrite* (if triggered via other autocmd)
|
|
||||||
" BufHidden for for compatibility with `set hidden`
|
|
||||||
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
|
|
||||||
autocmd BufWinEnter ?* silent! loadview
|
|
||||||
augroup end
|
|
||||||
|
|
||||||
" Comment no file types with #
|
|
||||||
autocmd BufNewFile,BufRead * if empty(&filetype) | setlocal commentstring=#\ %s | endif
|
|
||||||
" autocmd BufRead urls set commentstring=#\ %s
|
|
||||||
" set commentstring=#\ %s
|
|
||||||
|
|
||||||
|
|
||||||
" Do not edit readonly buffers
|
|
||||||
autocmd BufRead *.orig set readonly
|
|
||||||
autocmd BufRead *.pacnew set readonly
|
|
||||||
autocmd BufRead *.bak set readonly
|
|
||||||
autocmd BufWritePost *sxhkdrc !pkill -USR1 sxhkd
|
|
||||||
autocmd FileType netrw setl bufhidden=wipe
|
|
||||||
let g:netrw_fastbrowse = 0
|
|
||||||
|
|
||||||
" Toggle crates plugin on opening cargo.toml file
|
|
||||||
autocmd BufRead Cargo.toml call crates#toggle()
|
|
||||||
|
|
||||||
|
|
||||||
" Set python global file
|
|
||||||
let g:python3_host_prog = "/usr/bin/python"
|
|
||||||
" asmsyntax always nasm
|
|
||||||
let g:asmsyntax = 'nasm'
|
|
||||||
" set nodejs global prog
|
|
||||||
" let g:node_host_prog = "/usr/bin/neovim-node-host"
|
|
||||||
|
|
||||||
" Themeing
|
|
||||||
syntax on
|
|
||||||
let g:sonokai_style = "default"
|
|
||||||
let g:sonokai_transparent_background = 1
|
|
||||||
colorscheme sonokai
|
|
||||||
|
|
||||||
hi link Crates WarningMsg
|
|
||||||
|
|
||||||
if exists('+termguicolors')
|
|
||||||
let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
|
|
||||||
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
|
|
||||||
endif
|
|
||||||
let &t_Cs = "\e[4:3m"
|
|
||||||
let &t_Ce = "\e[4:0m"
|
|
||||||
|
|
||||||
" Rust
|
|
||||||
let g:rustfmt_autosave = 1
|
|
||||||
|
|
||||||
nnoremap <silent> <leader>da :call <SID>AppendBreakPoint()<CR>
|
|
||||||
nnoremap <silent> <leader>dc :call <SID>ClearBreakpoints()<CR>
|
|
||||||
nnoremap <silent> <leader>dr :call <SID>DebugRun()<CR>
|
|
||||||
|
|
||||||
function! s:AppendBreakPoint()
|
|
||||||
let s:breakpoint = "break ".expand('%').":".line('.')
|
|
||||||
call writefile([s:breakpoint], "./target/breakpoints", "a")
|
|
||||||
echom "Added breakpoint at line ".line('.')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:ClearBreakpoints()
|
|
||||||
call delete("./target/breakpoints")
|
|
||||||
echom "Cleared breakpoints"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:DebugRun()
|
|
||||||
execute "!cargo build"
|
|
||||||
let s:dirlist = split(getcwd(),'/')
|
|
||||||
let s:projectname = s:dirlist[len(s:dirlist)-1]
|
|
||||||
" let s:projectname = system('sed -n "s/^name Cargo.toml ')
|
|
||||||
let s:executable = getcwd()."/target/debug/".s:projectname
|
|
||||||
silent execute "!alacritty -e rust-gdb -x ./target/breakpoints ".s:executable." &"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"##################################################
|
|
||||||
"# Functions
|
|
||||||
"##################################################
|
|
||||||
" COC.nvim
|
|
||||||
" function! s:check_back_space() abort
|
|
||||||
" let col = col('.') - 1
|
|
||||||
" return !col || getline('.')[col - 1] =~# '\s'
|
|
||||||
" endfunction
|
|
||||||
|
|
||||||
" function! s:show_documentation()
|
|
||||||
" if (index(['vim','help'], &filetype) >= 0)
|
|
||||||
" execute 'h '.expand('<cword>')
|
|
||||||
" else
|
|
||||||
" call CocAction('doHover')
|
|
||||||
" endif
|
|
||||||
" endfunction
|
|
||||||
|
|
||||||
" Mpc
|
|
||||||
function Mpcfzf()
|
|
||||||
execute("silent !mpcfzf")
|
|
||||||
endfunction
|
|
||||||
" Mpc Current song
|
|
||||||
function CurrentSong()
|
|
||||||
let s = execute("!mpc | head -1")
|
|
||||||
return s
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let t:zen = 1
|
|
||||||
let t:fullscreen = 1
|
|
||||||
let t:tmux = 1
|
|
||||||
function! ZenToggle()
|
|
||||||
if t:zen == 0
|
|
||||||
hi Normal guibg=NONE ctermbg=NONE
|
|
||||||
hi NonText guibg=NONE ctermbg=NONE
|
|
||||||
TZMinimalistT
|
|
||||||
if t:tmux == 1
|
|
||||||
silent! !tmux set -g status on
|
|
||||||
endif
|
|
||||||
if t:fullscreen == 1
|
|
||||||
silent! !bspc node focused -f -t tiled
|
|
||||||
endif
|
|
||||||
let t:zen = 1
|
|
||||||
else
|
|
||||||
hi Normal ctermfg=255 ctermbg=234 cterm=NONE guifg=#EEEEEE guibg=#1C1C1C gui=NONE
|
|
||||||
hi NonText ctermfg=234 ctermbg=234 cterm=NONE guifg=#1C1C1C guibg=#1C1C1C gui=NONE
|
|
||||||
TZMinimalistF
|
|
||||||
if t:tmux == 1
|
|
||||||
silent! !tmux set -g status off
|
|
||||||
endif
|
|
||||||
if t:fullscreen == 1
|
|
||||||
silent! !bspc node focused -f -t fullscreen
|
|
||||||
endif
|
|
||||||
let t:zen = 0
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" ########################################
|
|
||||||
" # LUA
|
|
||||||
" ########################################
|
|
||||||
|
|
||||||
|
|
||||||
" Which key
|
|
||||||
lua << EOF
|
|
||||||
require("which-key").setup {
|
|
||||||
-- your configuration comes here
|
|
||||||
-- or leave it empty to use the default settings
|
|
||||||
-- refer to the configuration section below
|
|
||||||
}
|
|
||||||
-- Lspkind-nvim
|
|
||||||
require'lspkind'.init()
|
|
||||||
|
|
||||||
-- Colorizer
|
|
||||||
require'colorizer'.setup()
|
|
||||||
|
|
||||||
-- lsp trouble
|
|
||||||
require("trouble").setup {
|
|
||||||
-- your configuration comes here
|
|
||||||
-- or leave it empty to use the default settings
|
|
||||||
-- refer to the configuration section below
|
|
||||||
}
|
|
||||||
require("lsp");
|
|
||||||
require("scripts.status-line");
|
|
||||||
-- require("scripts.eviline");
|
|
||||||
require("scripts.truezen");
|
|
||||||
EOF
|
|
||||||
36
config/nvim/lua/colorscheme.lua
Normal file
36
config/nvim/lua/colorscheme.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
vim.o.termguicolors = true
|
||||||
|
vim.cmd[[colorscheme sonokai]]
|
||||||
|
local colors = {
|
||||||
|
black = '#181819',
|
||||||
|
bg0 = '#2c2e34',
|
||||||
|
bg1 = '#30323a',
|
||||||
|
bg2 = '#363944',
|
||||||
|
bg3 = '#3b3e48',
|
||||||
|
bg4 = '#414550',
|
||||||
|
|
||||||
|
bg_red = '#ff6077',
|
||||||
|
diff_red = '#55393d',
|
||||||
|
|
||||||
|
bg_green = '#a7df78',
|
||||||
|
diff_green = '#394634',
|
||||||
|
|
||||||
|
bg_blue = '#85d3f2',
|
||||||
|
diff_blue = '#354157',
|
||||||
|
|
||||||
|
diff_yellow = '#4e432f',
|
||||||
|
fg = '#e2e2e3',
|
||||||
|
|
||||||
|
red = '#fc5d7c',
|
||||||
|
orange = '#f39660',
|
||||||
|
yellow = '#e7c664',
|
||||||
|
green = '#9ed072',
|
||||||
|
blue = '#76cce0',
|
||||||
|
purple = '#b39df3',
|
||||||
|
grey = '#7f8490',
|
||||||
|
none = 'NONE',
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Override some colors
|
||||||
|
vim.cmd('hi Normal guibg='..colors.black)
|
||||||
|
vim.cmd('hi EndOfBuffer guibg='..colors.black)
|
||||||
|
-- vim.cmd('hi NonText guibg='..colors.black)
|
||||||
0
config/nvim/lua/functions.lua
Normal file
0
config/nvim/lua/functions.lua
Normal file
70
config/nvim/lua/keymaps.lua
Normal file
70
config/nvim/lua/keymaps.lua
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent=true})
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
|
local options = { noremap = true, silent = true }
|
||||||
|
local normal_mode_maps = {
|
||||||
|
-- toggles
|
||||||
|
{ key = '<F2>', map = [[<cmd>set number! relativenumber!<cr>]] },
|
||||||
|
|
||||||
|
-- navigation
|
||||||
|
{ key = '<leader><leader>', map = [[<c-^>]] },
|
||||||
|
{ key = '<leader>n', map = [[<cmd>bnext<cr>]] },
|
||||||
|
{ key = '<leader>p', map = [[<cmd>bprev<cr>]] },
|
||||||
|
{ key = '<leader>q', map = [[<cmd>bw<cr>]] },
|
||||||
|
|
||||||
|
-- fzf
|
||||||
|
{ key = '<leader>;', map = [[<cmd>Buffers<cr>]] },
|
||||||
|
{ key = '<leader>f', map = [[<cmd>Files<cr>]] },
|
||||||
|
{ key = '<leader>g', map = [[<cmd>Rg<cr>]] },
|
||||||
|
|
||||||
|
-- lsp
|
||||||
|
{ key = 'K', map = [[<cmd>lua vim.lsp.buf.hover()<cr>]] },
|
||||||
|
{ key = 'gd', map = [[<cmd>lua vim.lsp.buf.definition()<cr>]] },
|
||||||
|
{ key = 'gi', map = [[<cmd>lua vim.lsp.buf.implementation()<cr>]] },
|
||||||
|
{ key = '<leader>o', map = [[<cmd>LspTroubleToggle<cr>]] },
|
||||||
|
{ key = '<leader>a', map = [[<cmd>lua vim.lsp.buf.document_highlight()<cr>]] },
|
||||||
|
{ key = '<leader>c', map = [[<cmd>lua vim.lsp.buf.clear_references()<cr>]] },
|
||||||
|
{ key = 'F', map = [[<cmd>lua vim.lsp.buf.formatting()<cr>]] },
|
||||||
|
|
||||||
|
-- Other
|
||||||
|
{ key = '<leader>m', map = [[<cmd>silent !mpcfzf<cr>]] },
|
||||||
|
}
|
||||||
|
|
||||||
|
local insert_mode_maps = {
|
||||||
|
{
|
||||||
|
key = '<Tab>',
|
||||||
|
map = [[pumvisible() ? "\<C-n>" : "\<Tab>"]],
|
||||||
|
options = { noremap = true, silent = true, expr = true }
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
key = '<S-Tab>',
|
||||||
|
map = [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]],
|
||||||
|
options = { noremap = true, silent = true, expr = true }
|
||||||
|
},
|
||||||
|
|
||||||
|
-- { key = '<tab>', map = '(completion_smart_tab)', options = { plug = true } },
|
||||||
|
-- { key = '<s-tab>', map = '(completion_smart_s_tab)', options = { plug = true } },
|
||||||
|
|
||||||
|
{ key = '<C-j>', map = '<ESC>' },
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for idx = 1, #normal_mode_maps do
|
||||||
|
if normal_mode_maps[idx].options then
|
||||||
|
local options = normal_mode_maps[idx].options
|
||||||
|
vim.api.nvim_set_keymap('n', normal_mode_maps[idx].key, normal_mode_maps[idx].map ,options)
|
||||||
|
else
|
||||||
|
vim.api.nvim_set_keymap('n', normal_mode_maps[idx].key, normal_mode_maps[idx].map ,options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for idx = 1, #insert_mode_maps do
|
||||||
|
if insert_mode_maps[idx].options then
|
||||||
|
local options = insert_mode_maps[idx].options
|
||||||
|
vim.api.nvim_set_keymap('i', insert_mode_maps[idx].key, insert_mode_maps[idx].map ,options)
|
||||||
|
else
|
||||||
|
vim.api.nvim_set_keymap('i', insert_mode_maps[idx].key, insert_mode_maps[idx].map ,options)
|
||||||
|
end
|
||||||
|
end
|
||||||
14
config/nvim/lua/lsp/init.lua
Normal file
14
config/nvim/lua/lsp/init.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- local lspstatus = require('lsp-status')
|
||||||
|
-- lspstatus.register_progress()
|
||||||
|
|
||||||
|
require("lsp.rust-analyzer")
|
||||||
|
require("lsp.lua-language-server")
|
||||||
|
|
||||||
|
-- Set completeopt to have a better completion experience
|
||||||
|
vim.o.completeopt= "menuone,noinsert,noselect"
|
||||||
|
|
||||||
|
-- vim.api.nvim_command [[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]]
|
||||||
|
-- vim.api.nvim_command [[autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()]]
|
||||||
|
-- vim.api.nvim_command [[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]]
|
||||||
|
--
|
||||||
|
vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
18
config/nvim/lua/lsp/lua-language-server.lua
Normal file
18
config/nvim/lua/lsp/lua-language-server.lua
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
local lspconfig = require'lspconfig'
|
||||||
|
-- local lspstatus = require('lsp-status')
|
||||||
|
|
||||||
|
require'lspconfig'.sumneko_lua.setup{
|
||||||
|
cmd = { "lua-language-server" },
|
||||||
|
on_attach=function(client) require'completion'.on_attach(client) require'lsp-status'.on_attach(client) return end,
|
||||||
|
-- on_attach=require'completion'.on_attach,
|
||||||
|
filetypes = { "lua" },
|
||||||
|
log_level = 2,
|
||||||
|
root_dir = lspconfig.util.root_pattern(".git"),
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
telemetry = {
|
||||||
|
enable = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
config/nvim/lua/lsp/rust-analyzer.lua
Normal file
22
config/nvim/lua/lsp/rust-analyzer.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-- Built in lsp
|
||||||
|
local lspconfig = require'lspconfig'
|
||||||
|
-- local lspstatus = require('lsp-status')
|
||||||
|
-- lspstatus.register_progress()
|
||||||
|
|
||||||
|
lspconfig.rust_analyzer.setup{
|
||||||
|
on_attach=function(client) require'completion'.on_attach(client) require'lsp-status'.on_attach(client) return end,
|
||||||
|
cmd = { "rust-analyzer" },
|
||||||
|
filetypes = { "rust" },
|
||||||
|
root_dir = lspconfig.util.root_pattern("Cargo.toml"),
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
checkOnSave = {
|
||||||
|
command = "clippy";
|
||||||
|
},
|
||||||
|
cargo = {
|
||||||
|
allFeatures = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
73
config/nvim/lua/plugins.lua
Normal file
73
config/nvim/lua/plugins.lua
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
local execute = vim.api.nvim_command
|
||||||
|
local fn = vim.fn
|
||||||
|
|
||||||
|
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||||
|
|
||||||
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
|
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path})
|
||||||
|
execute 'packadd packer.nvim'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return require('packer').startup(function()
|
||||||
|
-- Packer can manage itself
|
||||||
|
use 'wbthomason/packer.nvim'
|
||||||
|
|
||||||
|
use {
|
||||||
|
'glepnir/galaxyline.nvim', branch = 'main',
|
||||||
|
config = function() require('statusline') end,
|
||||||
|
requires = { 'kyazdani42/nvim-web-devicons' }
|
||||||
|
}
|
||||||
|
|
||||||
|
use {
|
||||||
|
'sainnhe/sonokai',
|
||||||
|
config = function() require('colorscheme') end,
|
||||||
|
}
|
||||||
|
|
||||||
|
use {
|
||||||
|
'folke/which-key.nvim',
|
||||||
|
config = function() require("which-key").setup() end,
|
||||||
|
}
|
||||||
|
|
||||||
|
use { 'yuttie/comfortable-motion.vim' }
|
||||||
|
|
||||||
|
use {
|
||||||
|
'junegunn/fzf',
|
||||||
|
requires = { 'junegunn/fzf.vim' }
|
||||||
|
}
|
||||||
|
|
||||||
|
use {
|
||||||
|
'tpope/vim-surround',
|
||||||
|
'tpope/vim-vinegar',
|
||||||
|
'tpope/vim-repeat',
|
||||||
|
'tpope/vim-speeddating',
|
||||||
|
'tpope/vim-commentary',
|
||||||
|
'tpope/vim-fugitive',
|
||||||
|
}
|
||||||
|
use { 'norcalli/nvim-colorizer.lua', config = function() require'colorizer'.setup() end, }
|
||||||
|
|
||||||
|
-- lsp
|
||||||
|
use { 'onsails/lspkind-nvim', config = function() require'lspkind'.init() end, }
|
||||||
|
use { 'folke/lsp-trouble.nvim', config = function() require("trouble").setup {} end, }
|
||||||
|
use { 'neovim/nvim-lspconfig', config = function() require("lsp") end, }
|
||||||
|
use { 'nvim-lua/completion-nvim' }
|
||||||
|
use { 'nvim-lua/lsp-status.nvim' }
|
||||||
|
use {
|
||||||
|
'nvim-lua/lsp_extensions.nvim',
|
||||||
|
config =
|
||||||
|
function()
|
||||||
|
vim.api.nvim_command([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints{}]])
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
use { 'airblade/vim-rooter' }
|
||||||
|
|
||||||
|
-- rust {{{
|
||||||
|
use {
|
||||||
|
'rust-lang/rust.vim',
|
||||||
|
'mhinz/vim-crates',
|
||||||
|
'cespare/vim-toml',
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
end)
|
||||||
169
config/nvim/lua/statusline.lua
Normal file
169
config/nvim/lua/statusline.lua
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
local vim = vim
|
||||||
|
local gl = require('galaxyline')
|
||||||
|
|
||||||
|
local condition = require('galaxyline.condition')
|
||||||
|
-- local diagnostic = require('galaxyline.provider_diagnostic')
|
||||||
|
local diagnostics = require('lsp-status.diagnostics')
|
||||||
|
local vcs = require('galaxyline.provider_vcs')
|
||||||
|
local fileinfo = require('galaxyline.provider_fileinfo')
|
||||||
|
-- local extension = require('galaxyline.provider_extensions')
|
||||||
|
-- local colors = require('galaxyline.colors')
|
||||||
|
-- local buffer = require('galaxyline.provider_buffer')
|
||||||
|
-- local whitespace = require('galaxyline.provider_whitespace')
|
||||||
|
-- local lspclient = require('galaxyline.provider_lsp')
|
||||||
|
local lspstatus = require('lsp-status')
|
||||||
|
|
||||||
|
|
||||||
|
-- local gls = gl.section
|
||||||
|
gl.short_line_list = { 'defx' }
|
||||||
|
|
||||||
|
-- from sonokai theme (https://github.com/sainnhe/sonokai/blob/master/autoload/sonokai.vim)
|
||||||
|
local colors = {
|
||||||
|
dark_black = '#151515',
|
||||||
|
black = '#181819',
|
||||||
|
bg0 = '#2c2e34',
|
||||||
|
bg1 = '#30323a',
|
||||||
|
bg2 = '#363944',
|
||||||
|
bg3 = '#3b3e48',
|
||||||
|
bg4 = '#414550',
|
||||||
|
|
||||||
|
bg_red = '#ff6077',
|
||||||
|
diff_red = '#55393d',
|
||||||
|
|
||||||
|
bg_green = '#a7df78',
|
||||||
|
diff_green = '#394634',
|
||||||
|
|
||||||
|
bg_blue = '#85d3f2',
|
||||||
|
diff_blue = '#354157',
|
||||||
|
|
||||||
|
diff_yellow = '#4e432f',
|
||||||
|
fg = '#e2e2e3',
|
||||||
|
|
||||||
|
red = '#fc5d7c',
|
||||||
|
orange = '#f39660',
|
||||||
|
yellow = '#e7c664',
|
||||||
|
green = '#9ed072',
|
||||||
|
blue = '#76cce0',
|
||||||
|
purple = '#b39df3',
|
||||||
|
grey = '#7f8490',
|
||||||
|
none = 'NONE',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local mode_color = function()
|
||||||
|
local mode_colors = {
|
||||||
|
n = colors.blue,
|
||||||
|
i = colors.green,
|
||||||
|
c = colors.yellow,
|
||||||
|
V = colors.purple,
|
||||||
|
[''] = colors.purple,
|
||||||
|
v = colors.purple,
|
||||||
|
R = colors.red,
|
||||||
|
}
|
||||||
|
|
||||||
|
local color = mode_colors[vim.fn.mode()]
|
||||||
|
|
||||||
|
if color == nil then
|
||||||
|
color = colors.red
|
||||||
|
end
|
||||||
|
|
||||||
|
return color
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local gls = gl.section
|
||||||
|
|
||||||
|
gls.left[1] = {
|
||||||
|
ViMode = {
|
||||||
|
provider = function()
|
||||||
|
local alias = {
|
||||||
|
n = 'NORMAL',
|
||||||
|
i = 'INSERT',
|
||||||
|
c = 'COMMAND',
|
||||||
|
V = 'VISUAL',
|
||||||
|
[''] = 'VISUAL',
|
||||||
|
v = 'VISUAL',
|
||||||
|
R = 'REPLACE',
|
||||||
|
}
|
||||||
|
vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color())
|
||||||
|
local alias_mode = alias[vim.fn.mode()]
|
||||||
|
if alias_mode == nil then
|
||||||
|
alias_mode = vim.fn.mode()
|
||||||
|
end
|
||||||
|
return '▋ '..alias_mode..' '
|
||||||
|
end,
|
||||||
|
highlight = { colors.fg , colors.bg2 },
|
||||||
|
separator = '',
|
||||||
|
separator_highlight = { colors.bg2 ,
|
||||||
|
function()
|
||||||
|
if condition.check_git_workspace() then
|
||||||
|
return colors.bg1
|
||||||
|
else
|
||||||
|
return colors.dark_black
|
||||||
|
end
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- gls.left[2] = {
|
||||||
|
-- GitIcon = {
|
||||||
|
-- provider = function() return ' ' end,
|
||||||
|
-- condition = condition.check_git_workspace,
|
||||||
|
-- highlight = { colors.purple , colors.bg1 },
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
|
||||||
|
gls.left[2] = {
|
||||||
|
GitBranch = {
|
||||||
|
provider = function() return vcs.get_git_branch()..' ' end,
|
||||||
|
condition = condition.check_git_workspace,
|
||||||
|
highlight = { colors.purple , colors.bg1 },
|
||||||
|
icon = ' ',
|
||||||
|
separator = '',
|
||||||
|
separator_highlight = { colors.bg1 , colors.dark_black },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gls.left[3] = {
|
||||||
|
ShowLspStatus = {
|
||||||
|
provider = lspstatus.status,
|
||||||
|
-- condition = function ()
|
||||||
|
-- local tbl = {['dashboard'] = true,['']=true}
|
||||||
|
-- if tbl[vim.bo.filetype] then
|
||||||
|
-- return false
|
||||||
|
-- end
|
||||||
|
-- return true
|
||||||
|
-- end,
|
||||||
|
-- icon = ' LSP:',
|
||||||
|
highlight = { colors.diff_yellow , colors.dark_black, 'bold' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- Right Side
|
||||||
|
gls.right[1]= {
|
||||||
|
FileFormat = {
|
||||||
|
provider = function() return ' '..fileinfo.get_file_format()..' ' end,
|
||||||
|
highlight = { colors.purple, colors.bg3 },
|
||||||
|
separator = '',
|
||||||
|
separator_highlight = { colors.bg3, colors.dark_black },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gls.right[2] = {
|
||||||
|
LineInfo = {
|
||||||
|
provider = 'LineColumn',
|
||||||
|
highlight = { colors.grey, colors.bg2 },
|
||||||
|
separator = '',
|
||||||
|
separator_highlight = { colors.bg2, colors.bg3 },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
gls.right[3] = {
|
||||||
|
PerCent = {
|
||||||
|
provider = 'LinePercent',
|
||||||
|
highlight = { colors.blue, colors.bg1 },
|
||||||
|
separator = '',
|
||||||
|
separator_highlight = { colors.bg1 , colors.bg2 },
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user