Remove plugins I never use and move stuff into neo vim for LSP
This commit is contained in:
parent
3f54411d7b
commit
eec7d8e602
2 changed files with 62 additions and 53 deletions
|
@ -1 +1,61 @@
|
||||||
source ~/.vimrc
|
source ~/.vimrc
|
||||||
|
|
||||||
|
lua << EOF
|
||||||
|
require'lspconfig'.phpactor.setup{}
|
||||||
|
require'lspconfig'.vuels.setup{}
|
||||||
|
require'lspconfig'.vimls.setup{}
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
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', '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)
|
||||||
|
|
||||||
|
-- Set some keybinds conditional on server capabilities
|
||||||
|
if client.resolved_capabilities.document_formatting then
|
||||||
|
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||||
|
elseif client.resolved_capabilities.document_range_formatting then
|
||||||
|
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set autocommands conditional on server_capabilities
|
||||||
|
if client.resolved_capabilities.document_highlight then
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
|
||||||
|
hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
|
||||||
|
hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
|
||||||
|
augroup lsp_document_highlight
|
||||||
|
autocmd! * <buffer>
|
||||||
|
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||||
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||||
|
augroup END
|
||||||
|
]], false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use a loop to conveniently both setup defined servers
|
||||||
|
-- and map buffer local keybindings when the language server attaches
|
||||||
|
local servers = { "pyright", "rust_analyzer", "tsserver" }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
nvim_lsp[lsp].setup { on_attach = on_attach }
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
|
55
.vimrc
55
.vimrc
|
@ -1,17 +1,10 @@
|
||||||
" Specify a directory for plugins
|
|
||||||
" - For Neovim: stdpath('data') . '/plugged'
|
|
||||||
" - Avoid using standard Vim directory names like 'plugin'
|
|
||||||
call plug#begin('~/.vim/plugged')
|
call plug#begin('~/.vim/plugged')
|
||||||
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'easymotion/vim-easymotion'
|
Plug 'easymotion/vim-easymotion'
|
||||||
Plug 'adelarsq/vim-matchit'
|
Plug 'adelarsq/vim-matchit'
|
||||||
Plug 'bronson/vim-trailing-whitespace'
|
Plug 'bronson/vim-trailing-whitespace'
|
||||||
Plug 'terryma/vim-multiple-cursors'
|
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
Plug 'dense-analysis/ale'
|
|
||||||
Plug 'beanworks/vim-phpfmt'
|
|
||||||
Plug 'StanAngeloff/php.vim'
|
|
||||||
Plug 'arnaud-lb/vim-php-namespace', {'for': 'php'}
|
Plug 'arnaud-lb/vim-php-namespace', {'for': 'php'}
|
||||||
Plug 'vim-vdebug/vdebug'
|
|
||||||
Plug 'scrooloose/nerdtree'
|
Plug 'scrooloose/nerdtree'
|
||||||
Plug 'Xuyuanp/nerdtree-git-plugin'
|
Plug 'Xuyuanp/nerdtree-git-plugin'
|
||||||
Plug 'fholgado/minibufexpl.vim'
|
Plug 'fholgado/minibufexpl.vim'
|
||||||
|
@ -28,51 +21,6 @@ let NERDTreeShowHidden=1
|
||||||
" Close vim if the only window left open is a NERDTree
|
" Close vim if the only window left open is a NERDTree
|
||||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
||||||
|
|
||||||
"" ALE config
|
|
||||||
" Define fixers
|
|
||||||
let g:ale_fixers = {
|
|
||||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
|
||||||
\ 'javascript': ['eslint'],
|
|
||||||
\ 'php': ['phpcbf'],
|
|
||||||
\ 'rust': ['rustfmt'],
|
|
||||||
\}
|
|
||||||
|
|
||||||
" Run linter on save
|
|
||||||
let g:ale_fix_on_save = 1
|
|
||||||
let g:ale_linters = {
|
|
||||||
\ 'rust': ['rls', 'cargo']
|
|
||||||
\}
|
|
||||||
|
|
||||||
" Enable completion where available.
|
|
||||||
let g:ale_completion_enabled = 1
|
|
||||||
set omnifunc=ale#completion#OmniFunc
|
|
||||||
|
|
||||||
"" Gutentags
|
|
||||||
" Auto generate ctags on startup
|
|
||||||
autocmd! User vim-gutentags call gutentags#setup_gutentags()
|
|
||||||
|
|
||||||
"" PHP
|
|
||||||
" PHP Namespace: Automatically use fully qualified name
|
|
||||||
function! IPhpExpandClass()
|
|
||||||
call PhpExpandClass()
|
|
||||||
call feedkeys('a', 'n')
|
|
||||||
endfunction
|
|
||||||
autocmd FileType php inoremap <Leader>e <Esc>:call IPhpExpandClass()<CR>
|
|
||||||
autocmd FileType php noremap <Leader>e :call PhpExpandClass()<CR>
|
|
||||||
|
|
||||||
"" vdebug config
|
|
||||||
" Set xdebug config
|
|
||||||
let g:vdebug_options = {'ide_key': 'PHPSTORM'}
|
|
||||||
let g:vdebug_options = {'break_on_open': 0}
|
|
||||||
let g:vdebug_options = {'server': '172.17.0.1'}
|
|
||||||
let g:vdebug_options = {'port': '9002'}
|
|
||||||
|
|
||||||
" Configure paths
|
|
||||||
let g:vdebug_options["path_maps"] = { "/var/www/html": getcwd() }
|
|
||||||
|
|
||||||
" Don't break on open
|
|
||||||
let g:vdebug_options['break_on_open'] = 0
|
|
||||||
|
|
||||||
"" CtrlP config
|
"" CtrlP config
|
||||||
" Self explainatory
|
" Self explainatory
|
||||||
let g:ctrlp_max_files=0
|
let g:ctrlp_max_files=0
|
||||||
|
@ -95,3 +43,4 @@ set expandtab
|
||||||
set autoindent
|
set autoindent
|
||||||
|
|
||||||
let mapleader=" "
|
let mapleader=" "
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue