chore: changed to cmp, cause better
This commit is contained in:
parent
c4cb9eb777
commit
f36f6c0193
5 changed files with 249 additions and 75 deletions
135
.config/nvim/lua/plugins/cmp.lua
Normal file
135
.config/nvim/lua/plugins/cmp.lua
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||||
|
if not cmp_status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||||
|
if not snip_status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
require("luasnip/loaders/from_vscode").lazy_load()
|
||||||
|
|
||||||
|
local check_backspace = function()
|
||||||
|
local col = vim.fn.col "." - 1
|
||||||
|
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- פּ ﯟ some other good icons
|
||||||
|
local kind_icons = {
|
||||||
|
Text = "",
|
||||||
|
Method = "m",
|
||||||
|
Function = "",
|
||||||
|
Constructor = "",
|
||||||
|
Field = "",
|
||||||
|
Variable = "",
|
||||||
|
Class = "",
|
||||||
|
Interface = "",
|
||||||
|
Module = "",
|
||||||
|
Property = "",
|
||||||
|
Unit = "",
|
||||||
|
Value = "",
|
||||||
|
Enum = "",
|
||||||
|
Keyword = "",
|
||||||
|
Snippet = "",
|
||||||
|
Color = "",
|
||||||
|
File = "",
|
||||||
|
Reference = "",
|
||||||
|
Folder = "",
|
||||||
|
EnumMember = "",
|
||||||
|
Constant = "",
|
||||||
|
Struct = "",
|
||||||
|
Event = "",
|
||||||
|
Operator = "",
|
||||||
|
TypeParameter = "",
|
||||||
|
}
|
||||||
|
-- find more here: https://www.nerdfonts.com/cheat-sheet
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
|
||||||
|
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
|
||||||
|
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||||
|
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||||
|
["<C-e>"] = cmp.mapping {
|
||||||
|
i = cmp.mapping.abort(),
|
||||||
|
c = cmp.mapping.close(),
|
||||||
|
},
|
||||||
|
-- Accept currently selected item. If none selected, `select` first item.
|
||||||
|
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expandable() then
|
||||||
|
luasnip.expand()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
elseif check_backspace() then
|
||||||
|
fallback()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
"i",
|
||||||
|
"s",
|
||||||
|
}),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
"i",
|
||||||
|
"s",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = { "kind", "abbr", "menu" },
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
-- Kind icons
|
||||||
|
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||||
|
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
|
||||||
|
vim_item.menu = ({
|
||||||
|
nvim_lsp = "(LSP)",
|
||||||
|
luasnip = "(Snippet)",
|
||||||
|
buffer = "(Text)",
|
||||||
|
path = "(Path)",
|
||||||
|
})[entry.source.name]
|
||||||
|
return vim_item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "path" },
|
||||||
|
},
|
||||||
|
confirm_opts = {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = false,
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
completion = cmp.config.window.bordered({
|
||||||
|
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None"
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
experimental = {
|
||||||
|
ghost_text = false,
|
||||||
|
native_menu = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,26 +37,51 @@ local on_attach = function(client, bufnr)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local lsp = require "lspconfig"
|
--local lsp = require "lspconfig"
|
||||||
local coq = require "coq"
|
--local coq = require "coq"
|
||||||
|
--
|
||||||
lsp['hls'].setup{
|
--lsp['hls'].setup{
|
||||||
on_attach = on_attach,
|
-- on_attach = on_attach,
|
||||||
flags = lsp_flags,
|
-- flags = lsp_flags,
|
||||||
}
|
--}
|
||||||
lsp['rust_analyzer'].setup{}
|
--
|
||||||
|
--lsp['rust_analyzer'].setup{}
|
||||||
lsp.rust_analyzer.setup(
|
--
|
||||||
coq.lsp_ensure_capabilities{
|
--lsp.rust_analyzer.setup(
|
||||||
on_attach = on_attach,
|
-- coq.lsp_ensure_capabilities{
|
||||||
flags = lsp_flags,
|
-- on_attach = on_attach,
|
||||||
-- Server-specific settings...
|
-- flags = lsp_flags,
|
||||||
settings = {
|
-- -- Server-specific settings...
|
||||||
["rust-analyzer"] = {}
|
-- settings = {
|
||||||
}
|
-- ["rust-analyzer"] = {}
|
||||||
}
|
-- }
|
||||||
)
|
-- }
|
||||||
require('lspconfig')['texlab'].setup{
|
--)
|
||||||
on_attach = on_attach,
|
--
|
||||||
flags = lsp_flags,
|
--lsp['texlab'].setup{
|
||||||
}
|
-- on_attach = on_attach,
|
||||||
|
-- flags = lsp_flags,
|
||||||
|
--}
|
||||||
|
--lsp['sumneko_lua'].setup{
|
||||||
|
--
|
||||||
|
-- settings = {
|
||||||
|
-- Lua = {
|
||||||
|
-- runtime = {
|
||||||
|
-- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
|
-- version = 'LuaJIT',
|
||||||
|
-- },
|
||||||
|
-- diagnostics = {
|
||||||
|
-- -- Get the language server to recognize the `vim` global
|
||||||
|
-- globals = {'vim'},
|
||||||
|
-- },
|
||||||
|
-- workspace = {
|
||||||
|
-- -- Make the server aware of Neovim runtime files
|
||||||
|
-- library = vim.api.nvim_get_runtime_file("", true),
|
||||||
|
-- },
|
||||||
|
-- -- Do not send telemetry data containing a randomized but unique identifier
|
||||||
|
-- telemetry = {
|
||||||
|
-- enable = false,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
--}
|
||||||
|
|
4
.config/nvim/lua/plugins/mason-lspconfig.lua
Normal file
4
.config/nvim/lua/plugins/mason-lspconfig.lua
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
require("mason-lspconfig").setup({
|
||||||
|
ensure_installed = { "sumneko_lua", "rust_analyzer" , "texlab"},
|
||||||
|
automatic_installation = true
|
||||||
|
})
|
|
@ -17,54 +17,76 @@ local plugins = packer.startup({function(use)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-------------------------------------------------------QOL----------------------------------------------
|
||||||
|
|
||||||
use { "ggandor/leap.nvim",
|
use { "ggandor/leap.nvim",
|
||||||
config = function ()
|
config = function ()
|
||||||
require('leap').add_default_mappings()
|
require('leap').add_default_mappings()
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use {'stevearc/dressing.nvim'} -- Rename variable pop up
|
||||||
|
|
||||||
|
use {"windwp/nvim-autopairs",
|
||||||
|
config = function() require("nvim-autopairs").setup {}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
-------------------------------------------------------LSP----------------------------------------------
|
||||||
|
|
||||||
|
use { "williamboman/mason.nvim",
|
||||||
|
config = function ()
|
||||||
|
require "plugins.mason"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
use { "williamboman/mason-lspconfig.nvim",
|
||||||
|
config = function ()
|
||||||
|
require "plugins.mason-lspconfig"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
use { "neovim/nvim-lspconfig",
|
use { "neovim/nvim-lspconfig",
|
||||||
config = function ()
|
config = function ()
|
||||||
require "plugins.lspconfig"
|
require "plugins.lspconfig"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
use {"ms-jpq/coq_nvim",
|
use { "L3MON4D3/LuaSnip",
|
||||||
branch = 'coq',
|
requires = {
|
||||||
config = function ()
|
"rafamadriz/friendly-snippets",
|
||||||
vim.g.coq_settings = { auto_start = 'shut-up'}
|
"saadparwaiz1/cmp_luasnip"
|
||||||
end
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
--------------------------------------------------SUGGESTION BOX-----------------------------------------
|
||||||
use {"ms-jpq/coq_nvim",
|
use { "hrsh7th/nvim-cmp",
|
||||||
branch = 'artifacts',
|
config = function()
|
||||||
}
|
require "plugins.cmp"
|
||||||
|
|
||||||
use {'stevearc/dressing.nvim'} -- Rename variable pop up
|
|
||||||
|
|
||||||
use {"windwp/nvim-autopairs",
|
|
||||||
config = function() require("nvim-autopairs").setup {} end
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
---- use { "L3MON4D3/LuaSnip",
|
|
||||||
-- requires = {
|
|
||||||
-- "rafamadriz/friendly-snippets",
|
|
||||||
---- "saadparwaiz1/cmp_luasnip"
|
|
||||||
-- },
|
|
||||||
-- }
|
|
||||||
use { "williamboman/mason.nvim",
|
|
||||||
config = function ()
|
|
||||||
require "plugins.mason"
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
--- use {"ms-jpq/coq_nvim",
|
||||||
|
--- branch = 'coq',
|
||||||
|
--- config = function ()
|
||||||
|
--- vim.g.coq_settings = { auto_start = 'shut-up'}
|
||||||
|
--- end
|
||||||
|
---
|
||||||
|
--- }
|
||||||
|
---
|
||||||
|
-- use {"ms-jpq/coq_nvim",
|
||||||
|
-- branch = 'artifacts',
|
||||||
|
-- }
|
||||||
|
-------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use {'nvim-tree/nvim-tree.lua',
|
use {'nvim-tree/nvim-tree.lua',
|
||||||
requires = {
|
requires = {
|
||||||
'nvim-tree/nvim-web-devicons', -- optional, for file icons
|
'nvim-tree/nvim-web-devicons', -- optional, for file icons
|
||||||
},
|
},
|
||||||
require("nvim-tree").setup()
|
config = function()
|
||||||
|
require("nvim-tree").setup()
|
||||||
|
end
|
||||||
}
|
}
|
||||||
use { "feline-nvim/feline.nvim" }
|
use { "feline-nvim/feline.nvim" }
|
||||||
|
|
||||||
|
@ -95,28 +117,28 @@ local plugins = packer.startup({function(use)
|
||||||
use {"jbyuki/instant.nvim"}
|
use {"jbyuki/instant.nvim"}
|
||||||
|
|
||||||
use {"narutoxy/silicon.lua",
|
use {"narutoxy/silicon.lua",
|
||||||
requires = { "nvim-lua/plenary.nvim" },
|
requires = { "nvim-lua/plenary.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
require('silicon').setup({
|
require('silicon').setup({
|
||||||
font = "FiraCode Nerd Font Mono",
|
font = "FiraCode Nerd Font Mono",
|
||||||
output = "~/Pictures/SILICON_${year}-${month}-${date}.png",
|
output = "~/Pictures/SILICON_${year}-${month}-${date}.png",
|
||||||
debug = true
|
debug = true
|
||||||
})
|
})
|
||||||
require "plugins.silicon"
|
require "plugins.silicon"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
use {"tpope/vim-surround"}
|
use {"tpope/vim-surround"}
|
||||||
|
|
||||||
use {"startup-nvim/startup.nvim",
|
use {"startup-nvim/startup.nvim",
|
||||||
requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"},
|
requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"},
|
||||||
config = function()
|
config = function()
|
||||||
require("startup").setup { theme = "dashboard" }
|
require("startup").setup { theme = "dashboard" }
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
auto_clean = true,
|
auto_clean = true,
|
||||||
compile_on_sync = true,
|
compile_on_sync = true,
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
local rt = require("rust-tools")
|
|
||||||
|
|
||||||
rt.setup({
|
|
||||||
server = {
|
|
||||||
on_attach = function(_, bufnr)
|
|
||||||
-- Hover actions
|
|
||||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
||||||
-- Code action groups
|
|
||||||
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
|
Loading…
Add table
Reference in a new issue