c288e11ac6
Remove vim plugins and configuration, move to using nvim init and vim-plug to manage plugins
177 lines
6.2 KiB
VimL
177 lines
6.2 KiB
VimL
" set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
|
" let &packpath = &runtimepath
|
|
" source ~/.vimrc
|
|
|
|
call plug#begin()
|
|
" The default plugin directory will be as follows:
|
|
" - Vim (Linux/macOS): '~/.vim/plugged'
|
|
" - Vim (Windows): '~/vimfiles/plugged'
|
|
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
|
|
" You can specify a custom plugin directory by passing it as the argument
|
|
" - e.g. `call plug#begin('~/.vim/plugged')`
|
|
" - Avoid using standard Vim directory names like 'plugin'
|
|
|
|
" Make sure you use single quotes
|
|
|
|
Plug 'neovim/nvim-lspconfig'
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
Plug 'joshdick/onedark.vim'
|
|
Plug 'mileszs/ack.vim'
|
|
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
|
Plug 'junegunn/fzf.vim'
|
|
Plug 'tpope/vim-unimpaired'
|
|
Plug 'tpope/vim-fugitive'
|
|
Plug 'airblade/vim-gitgutter'
|
|
Plug 'vim-airline/vim-airline'
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
Plug 'christoomey/vim-tmux-navigator'
|
|
|
|
" Initialize plugin system
|
|
call plug#end()
|
|
|
|
let g:python3_host_prog = '~/.pyenv/versions/base/bin/python'
|
|
|
|
lua << EOF
|
|
-- 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', vim.lsp.buf.formatting, bufopts)
|
|
end
|
|
|
|
local lsp_flags = {
|
|
-- This is the default in Nvim 0.7+
|
|
debounce_text_changes = 150,
|
|
}
|
|
require('lspconfig')['pylsp'].setup{
|
|
on_attach = on_attach,
|
|
flags = lsp_flags,
|
|
}
|
|
require('lspconfig')['fortls'].setup{
|
|
on_attach = on_attach,
|
|
flags = lsp_flags,
|
|
}
|
|
EOF
|
|
|
|
map ; :Files<CR>
|
|
if executable('ag')
|
|
let g:ackprg = 'ag --vimgrep'
|
|
endif
|
|
|
|
if exists('+termguicolors') && ($COLORTERM == "24bit" || $COLORTERM == "truecolor")
|
|
set termguicolors
|
|
endif
|
|
colorscheme onedark
|
|
|
|
set cursorline
|
|
let mapleader=","
|
|
|
|
set number
|
|
set relativenumber
|
|
set listchars=trail:.,tab:>_
|
|
set list
|
|
set wrap
|
|
set linebreak
|
|
set autoread
|
|
|
|
au BufRead,BufNewFile *.ipynb setlocal filetype=json
|
|
au BufRead,BufNewFile *.md setlocal spell
|
|
au BufRead,BufNewFile *.code-workspace setlocal filetype=json
|
|
au BufRead,BufNewFile *.csv setlocal nowrap
|
|
au BufRead,BufNewFile *.service[a-zA-Z0-9]* setlocal filetype=systemd
|
|
au TermOpen * setlocal nonumber norelativenumber
|
|
syntax on
|
|
|
|
if &diff
|
|
highlight! link DiffText MatchParen
|
|
endif
|
|
au OptionSet diff highlight! link DiffText MatchParen
|
|
|
|
set expandtab
|
|
set autoindent
|
|
set smartindent
|
|
filetype plugin indent on
|
|
|
|
imap jk <Esc>
|
|
command Bd b# | bd #
|
|
command! BufOnly silent! execute "%bd|e#|bd#"
|
|
nnoremap <Leader>b :buffers<CR>:buffer<Space>
|
|
nnoremap <Leader>i :!zimports %<CR>:!black %<CR><CR>
|
|
nnoremap <leader>n :NERDTreeFocus<CR>
|
|
nnoremap <C-n> :NERDTree<CR>
|
|
nnoremap <C-t> :NERDTreeToggle<CR>
|
|
nnoremap <C-f> :NERDTreeFind<CR>
|
|
nnoremap <Leader>a :Ack!<Space>
|
|
|
|
" 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
|
|
|
|
set splitbelow
|
|
set splitright
|
|
|
|
function! GitStatus()
|
|
let [a,m,r] = GitGutterGetHunkSummary()
|
|
return printf('%s +%d ~%d -%d', FugitiveHead(), a, m, r)
|
|
endfunction
|
|
|
|
let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+'
|
|
|
|
" let g:slime_target = "tmux"
|
|
" let g:slime_default_config = {"socket_name": get(split($TMUX, ","), 0), "target_pane": "{last}"}
|
|
|
|
" let g:lightline = { 'colorscheme': 'onehalfdark' }
|
|
" let g:lightline.component_expand = {
|
|
" \ 'linter_checking': 'lightline#ale#checking',
|
|
" \ 'linter_infos': 'lightline#ale#infos',
|
|
" \ 'linter_warnings': 'lightline#ale#warnings',
|
|
" \ 'linter_errors': 'lightline#ale#errors',
|
|
" \ 'linter_ok': 'lightline#ale#ok',
|
|
" \ }
|
|
" let g:lightline.component_type = {
|
|
" \ 'linter_checking': 'right',
|
|
" \ 'linter_infos': 'right',
|
|
" \ 'linter_warnings': 'warning',
|
|
" \ 'linter_errors': 'error',
|
|
" \ 'linter_ok': 'right',
|
|
" \ }
|
|
" let g:lightline.component_function = {
|
|
" \ 'gitstatus': 'GitStatus'
|
|
" \ }
|
|
" let g:lightline.active = {
|
|
" \ 'left': [ [ 'mode', 'paste' ],
|
|
" \ [ 'gitstatus', 'readonly', 'filename', 'modified' ] ],
|
|
" \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok', 'lineinfo' ],
|
|
" \ [ 'percent' ],
|
|
" \ [ 'fileformat', 'fileencoding', 'filetype' ] ]
|
|
" \ }
|
|
" set laststatus=0
|
|
" set noshowmode
|