Compare commits
2 Commits
d7df92eb95
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e85812630 | ||
|
|
a968cdc50a |
58
nvim/lua/olinpin/plugins/completion.lua
Normal file
58
nvim/lua/olinpin/plugins/completion.lua
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
event = "InsertEnter",
|
||||||
|
dependencies = {
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
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" }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "path" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
return {
|
|
||||||
"xavierchow/vim-sequence-diagram"
|
|
||||||
}
|
|
||||||
@@ -27,10 +27,10 @@ local PACKAGES = {
|
|||||||
-- Lint
|
-- Lint
|
||||||
"eslint-lsp",
|
"eslint-lsp",
|
||||||
"pylint",
|
"pylint",
|
||||||
"jq",
|
"jq",
|
||||||
"php-cs-fixer",
|
"php-cs-fixer",
|
||||||
"intelephense",
|
"intelephense",
|
||||||
"prettier",
|
"prettier",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function install(pack, version)
|
local function install(pack, version)
|
||||||
@@ -117,30 +117,30 @@ end
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
init = function()
|
init = function()
|
||||||
-- Do not crowd home directory with NPM cache folder
|
-- Do not crowd home directory with NPM cache folder
|
||||||
vim.env.npm_config_cache = vim.env.HOME .. "/.cache/npm"
|
vim.env.npm_config_cache = vim.env.HOME .. "/.cache/npm"
|
||||||
end,
|
end,
|
||||||
opts = {
|
opts = {
|
||||||
ui = {
|
ui = {
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
height = 0.85,
|
height = 0.85,
|
||||||
width = 0.8,
|
width = 0.8,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
config = function(_, opts)
|
||||||
config = function(_, opts)
|
require("mason").setup(opts)
|
||||||
require("mason").setup(opts)
|
|
||||||
|
|
||||||
-- Filter out disabled packages
|
-- Filter out disabled packages
|
||||||
local packages = {}
|
local packages = {}
|
||||||
for _, package in ipairs(PACKAGES) do
|
for _, package in ipairs(PACKAGES) do
|
||||||
table.insert(packages, package)
|
table.insert(packages, package)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
syncPackages(packages)
|
syncPackages(packages)
|
||||||
end, 3000)
|
end, 3000)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
event = { "VeryLazy" },
|
event = { "VeryLazy" },
|
||||||
},
|
},
|
||||||
@@ -148,6 +148,8 @@ return {
|
|||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
dependencies = { "williamboman/mason.nvim" },
|
dependencies = { "williamboman/mason.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
local opts = { buffer = bufnr, silent = true }
|
local opts = { buffer = bufnr, silent = true }
|
||||||
|
|
||||||
@@ -165,12 +167,13 @@ return {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Configure LSP servers using new vim.lsp.config API
|
-- Configure LSP servers using new vim.lsp.config API
|
||||||
vim.lsp.config('lua_ls', {
|
vim.lsp.config("lua_ls", {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = { version = 'LuaJIT' },
|
runtime = { version = "LuaJIT" },
|
||||||
diagnostics = { globals = { 'vim' } },
|
diagnostics = { globals = { "vim" } },
|
||||||
workspace = {
|
workspace = {
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
checkThirdParty = false,
|
checkThirdParty = false,
|
||||||
@@ -180,14 +183,24 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.lsp.config('ts_ls', { on_attach = on_attach })
|
vim.lsp.config("ts_ls", { on_attach = on_attach, capabilities = capabilities })
|
||||||
vim.lsp.config('pyright', { on_attach = on_attach })
|
vim.lsp.config("pyright", { on_attach = on_attach, capabilities = capabilities })
|
||||||
vim.lsp.config('html', { on_attach = on_attach })
|
vim.lsp.config("html", { on_attach = on_attach, capabilities = capabilities })
|
||||||
vim.lsp.config('cssls', { on_attach = on_attach })
|
vim.lsp.config("cssls", { on_attach = on_attach, capabilities = capabilities })
|
||||||
vim.lsp.config('jsonls', { on_attach = on_attach })
|
vim.lsp.config("jsonls", { on_attach = on_attach, capabilities = capabilities })
|
||||||
vim.lsp.config('yamlls', { on_attach = on_attach })
|
vim.lsp.config("yamlls", { on_attach = on_attach, capabilities = capabilities })
|
||||||
vim.lsp.config('intelephense', { on_attach = on_attach })
|
vim.lsp.config("intelephense", {
|
||||||
vim.lsp.config('eslint', { on_attach = on_attach })
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
intelephense = {
|
||||||
|
format = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vim.lsp.config("eslint", { on_attach = on_attach, capabilities = capabilities })
|
||||||
|
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
|
|||||||
Reference in New Issue
Block a user