From 688028ef1685c58f342c9dbd545f241f02b521e9 Mon Sep 17 00:00:00 2001 From: Sebsatian Keller Date: Wed, 23 Dec 2020 21:12:56 +0100 Subject: [PATCH 1/2] README.md: added nvim-lspconfig configuration It took me some time to get nvim-lspconfig working. This example configuration might be useful for others wanting to use nvim-lspconfig. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 40f21a0..e27de61 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ Install the `zls-vscode` extension from [here](https://github.com/zigtools/zls-v ``` ### Neovim/Vim8 +#### CoC - Install the CoC engine from [here](https://github.com/neoclide/coc.nvim). - Issue `:CocConfig` from within your Vim editor, and the following snippet: @@ -139,6 +140,44 @@ Install the `zls-vscode` extension from [here](https://github.com/zigtools/zls-v } ``` +#### nvim-lspconfig +Requires Nvim 0.5 (HEAD)! + +- Install nvim-lspconfig from [here](https://github.com/neovim/nvim-lspconfig). +- Install zig.vim from [here](https://github.com/ziglang/zig.vim). + +nvim-lspconfig ships already a configuration for zls. A simple `init.vim` might look like this: +```vim +call plug#begin('~/.config/nvim/plugged') +Plug 'neovim/nvim-lspconfig' +Plug 'nvim-lua/completion-nvim' +Plug 'ziglang/zig.vim' +call plug#end() + +:lua << EOF + local lspconfig = require('lspconfig') + + local on_attach = function(_, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + require('completion').on_attach() + end + + local servers = {'zls'} + for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + } + end +EOF + +" Set completeopt to have a better completion experience +set completeopt=menuone,noinsert,noselect + +" Enable completions as you type +let g:completion_enable_auto_popup = 1 +``` + + ### Emacs - Install [lsp-mode](https://github.com/emacs-lsp/lsp-mode) from melpa From 0ce1ef1ce778cf20f32eaf63760afb0db91b3801 Mon Sep 17 00:00:00 2001 From: Sebsatian Keller Date: Thu, 24 Dec 2020 01:04:45 +0100 Subject: [PATCH 2/2] Update README.md fixed wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e27de61..5781b83 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ Requires Nvim 0.5 (HEAD)! - Install nvim-lspconfig from [here](https://github.com/neovim/nvim-lspconfig). - Install zig.vim from [here](https://github.com/ziglang/zig.vim). -nvim-lspconfig ships already a configuration for zls. A simple `init.vim` might look like this: +nvim-lspconfig already ships a configuration for zls. A simple `init.vim` might look like this: ```vim call plug#begin('~/.config/nvim/plugged') Plug 'neovim/nvim-lspconfig'