diff --git a/.config/nvim/lua/.luarc.json b/.config/nvim/lua/.luarc.json index 1be9582..1cc3323 100644 --- a/.config/nvim/lua/.luarc.json +++ b/.config/nvim/lua/.luarc.json @@ -1,5 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.diagnostics.globals": [ + "vim" + ], "Lua.workspace.library": [ "/home/afonso/.config/nvim", "/etc/xdg/nvim", diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 86c738a..bc3f3ca 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -104,6 +104,8 @@ cmp.setup { nvim_lsp = "(LSP)", luasnip = "(Snippet)", buffer = "(Text)", + nvim_lsp_signature_help = "(Signature)", + nvim_lua = "(Nvim LSP)", path = "(Path)", })[entry.source.name] return vim_item @@ -118,8 +120,32 @@ cmp.setup { }, sources = cmp.config.sources( { - { name = "nvim_lsp" }, - { name = "luasnip" }, + { name = "nvim_lsp", + entry_filter = function(entry, context) + local kind = entry:get_kind() + local line = context.cursor_line + local col = context.cursor.col + local char_before_cursor = string.sub(line, col - 1, col) + + + if char_before_cursor == "." then + if kind == 2 or kind == 5 then + return true + else return false end + elseif string.match(line, "^%s*%w*$") then + if kind == 3 or kind == 6 then + return true + else + return false + end + end + return true + end + + }, + { name = 'nvim_lua' }, + { name = 'luasnip'}, + { name = 'nvim_lsp_signature_help' }, { name = "path" }, }, { diff --git a/.config/nvim/lua/plugins/packer.lua b/.config/nvim/lua/plugins/packer.lua index c717f3c..9e8c9f8 100644 --- a/.config/nvim/lua/plugins/packer.lua +++ b/.config/nvim/lua/plugins/packer.lua @@ -53,6 +53,8 @@ local plugins = packer.startup({ function(use) use { "hrsh7th/nvim-cmp", requires = { "hrsh7th/cmp-nvim-lsp", -- lsp + "hrsh7th/cmp-nvim-lua", -- Nvim API completions + "hrsh7th/cmp-nvim-lsp-signature-help", -- Show function signatures "hrsh7th/cmp-buffer", --buffer completions "hrsh7th/cmp-path", --path completions "hrsh7th/cmp-cmdline" --cmdline completions @@ -61,6 +63,12 @@ local plugins = packer.startup({ function(use) require "plugins.cmp" end } + + use { "L3MON4D3/LuaSnip", + requires = { + "saadparwaiz1/cmp_luasnip" + }, + } -------------------------------------------------------LSP---------------------------------------------- use { "williamboman/mason.nvim", @@ -71,8 +79,6 @@ local plugins = packer.startup({ function(use) use { "williamboman/mason-lspconfig.nvim" } - use { "hrsh7th/cmp-nvim-lsp"} - use { "neovim/nvim-lspconfig", config = function() require "plugins.lspconfig" @@ -85,12 +91,6 @@ local plugins = packer.startup({ function(use) end } - use { "L3MON4D3/LuaSnip", - requires = { - "rafamadriz/friendly-snippets", - "saadparwaiz1/cmp_luasnip" - }, - } ------------------------------------------------------------------------------------------