From 48af6cc3efb5846e2080c03eee9fc677bdb197f8 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 30 Sep 2021 10:57:37 -0700 Subject: [PATCH] nvim: Add better support for lsp via omnifunc Only reason I'm not using this is that there is no floating preview window --- neovim/lua/_settings.lua | 7 +++++++ neovim/lua/plugins/lsp.lua | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/neovim/lua/_settings.lua b/neovim/lua/_settings.lua index 34086fb..d03391b 100644 --- a/neovim/lua/_settings.lua +++ b/neovim/lua/_settings.lua @@ -1,5 +1,6 @@ local o = vim.o local g = vim.g +local utils = require("utils") -- Set leader to space g.mapleader = " " @@ -19,5 +20,11 @@ o.scrolloff = 3 -- o.mousehide = true o.mouse = "a" +-- Autocomplete options +o.completeopt = "menuone,noinsert,noselect,preview" +utils.augroup("close_preview", function() + vim.cmd("autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif") +end) + local has = vim.fn.has g.is_mac = (has("mac") or has("macunix") or has("gui_macvim") or vim.fn.system("uname"):find("^darwin") ~= nil) diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index 781068e..0edbdd1 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -1,6 +1,10 @@ -- luacheck: globals packer_plugins +local utils = require("utils") + local function default_attach(client, bufnr) - require('completion').on_attach() + if utils.is_plugin_loaded("completion-nvim") then + require('completion').on_attach() + end 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