aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-02-17 13:05:42 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-05-29 22:57:31 +0100
commit77cb4a8d7c3dcac52dab56f3005bde5310f74095 (patch)
tree41786dd6b8ac206d854561c1a8a8f50162e33898
parent4c8dbf4a790d58020977c8453392bcb34930af4c (diff)
downloaddotnvim-77cb4a8d7c3dcac52dab56f3005bde5310f74095.tar.gz
dotnvim-77cb4a8d7c3dcac52dab56f3005bde5310f74095.zip
Using neovim lsp support (for python initialy)
-rw-r--r--README.md7
-rw-r--r--init.vim2
-rw-r--r--lsc.vim27
-rw-r--r--lsp.lua50
-rw-r--r--vimrc7
5 files changed, 61 insertions, 32 deletions
diff --git a/README.md b/README.md
index fb4da3f..8383f44 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,10 @@
Managed by [vim-plug](https://github.com/junegunn/vim-plug).
-A few things require nvim 0.5.0 or later, but (hopefully) won't load if not possible.
+A few things require nvim at a specific version:
+
+ - nvim 0.5.0 or later: Scala LSP (metals), telescope, autocompleten
+ - nvim 0.6.1 or later: LSP support
For further information on installed plugins:
@@ -21,7 +24,7 @@ If you're not using vim 8; create a `.vimrc` with:
This can be also be used to customise your local vim configuration without
having uncommitted changes in your repository.
-In case of Neovim, you can link the provided `init.vim` into `~/.config/nvim/init.vim`.
+In case of neovim, you can link the provided `init.vim` into `~/.config/nvim/init.vim`.
Then it is recommended you run:
diff --git a/init.vim b/init.vim
index 480385f..434b892 100644
--- a/init.vim
+++ b/init.vim
@@ -6,7 +6,7 @@ source ~/.vimrc
" for LSC support
"
" general
-source ~/.vim/lsc.vim
+source ~/.vim/lsp.lua
" scala and metals
source ~/.vim/metals.vim
diff --git a/lsc.vim b/lsc.vim
deleted file mode 100644
index 5c6abd8..0000000
--- a/lsc.vim
+++ /dev/null
@@ -1,27 +0,0 @@
-" vim-lsc configuation
-"
-" req:
-" - python-lsp-server
-" - pylsp-mypy
-" - python-lsp-black
-"
-" ensure yapf and autopep8 is not installed so black works
-"
-let g:lsc_server_commands = {
- \ 'python': {
- \ 'command': 'pylsp',
- \ 'suppress_stderr': 0,
- \ 'workspace_config': {
- \ 'pylsp.plugins.pylsp_mypy.enabled': 1,
- \ 'pylsp.plugins.pylsp_mypy.live_mode': 0
- \ }
- \ },
- \ 'haskell' : {
- \ 'command': 'haskell-language-server-wrapper --lsp',
- \ 'suppress_stderr': 1
- \ }
- \ }
-
-let g:lsc_auto_map = {'defaults': v:true, 'FindImplementations': ''}
-let g:lsc_preview_split_direction = "below"
-
diff --git a/lsp.lua b/lsp.lua
new file mode 100644
index 0000000..10d5471
--- /dev/null
+++ b/lsp.lua
@@ -0,0 +1,50 @@
+-- for nvim lsp support
+
+-- Mappings.
+-- See `:help vim.diagnostic.*` for documentation on any of the below functions
+local opts = { noremap=true, silent=true }
+vim.api.nvim_set_keymap('n', '<leader>d', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
+vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
+vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
+vim.api.nvim_set_keymap('n', 'da', '<cmd>lua vim.diagnostic.setloclist()<CR>', 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
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-]>', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gsh', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>F', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
+end
+
+-- Use a loop to conveniently call 'setup' on multiple servers and
+-- map buffer local keybindings when the language server attaches
+local servers = { 'pylsp' }
+for _, lsp in pairs(servers) do
+ require('lspconfig')[lsp].setup {
+ on_attach = on_attach,
+ flags = {
+ -- This will be the default in neovim 0.7+
+ debounce_text_changes = 150,
+ },
+ settings = {
+ pylsp = {
+ plugins = {
+ pylsp_mypy = {
+ enabled = true,
+ live_move = false
+ }
+ }
+ }
+ }
+ }
+end
diff --git a/vimrc b/vimrc
index 4659c59..f8eb9e9 100644
--- a/vimrc
+++ b/vimrc
@@ -58,13 +58,11 @@ Plug 'plasticboy/vim-markdown'
Plug 'vimwiki/vimwiki'
" language support
-Plug 'natebosch/vim-lsc'
Plug 'samsaga2/vim-z80'
Plug 'tomtom/tcomment_vim'
Plug 'https://tildegit.org/sloum/gemini-vim-syntax.git'
Plug 'neovimhaskell/haskell-vim'
-" nvim 0.5.0 or later
if has('nvim-0.5')
" general lua
Plug 'nvim-lua/popup.nvim'
@@ -81,6 +79,11 @@ if has('nvim-0.5')
Plug 'hrsh7th/vim-vsnip'
end
+if has('nvim-0.6.1')
+ " lsp
+ Plug 'neovim/nvim-lspconfig'
+end
+
call plug#end()
" crystaline conf