This commit is contained in:
newbie 2023-12-19 12:02:11 +08:00
parent 317c612f41
commit 6b8fec654c
3 changed files with 24 additions and 7 deletions

0
lua/lsp/yaml.lua Normal file
View File

View File

@ -26,6 +26,7 @@ local kind_icons = {
TypeParameter = "󰅲", TypeParameter = "󰅲",
} }
local has_words_before = function() local has_words_before = function()
unpack = unpack or table.unpack unpack = unpack or table.unpack
local line, col = unpack(G.api.nvim_win_get_cursor(0)) local line, col = unpack(G.api.nvim_win_get_cursor(0))
@ -45,6 +46,8 @@ return {
require 'lspconfig'.clangd.setup(require('lsp.c')) require 'lspconfig'.clangd.setup(require('lsp.c'))
require 'lspconfig'.bashls.setup(require('lsp.bash')) require 'lspconfig'.bashls.setup(require('lsp.bash'))
require 'lspconfig'.pyright.setup(require('lsp.pyright')) require 'lspconfig'.pyright.setup(require('lsp.pyright'))
require 'lspconfig'.jsonls.setup({})
require('lspconfig').yamlls.setup(require("lsp.yaml"))
G.map({ G.map({
{ 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>' }, { 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>' },
@ -69,7 +72,9 @@ return {
"clangd", "clangd",
"bashls", "bashls",
"pyright", "pyright",
"lua_ls" "lua_ls",
"jsonls",
"yamlls"
} }
}) })
@ -278,7 +283,7 @@ return {
}), }),
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({ select = false }), ['<CR>'] = cmp.mapping.confirm({ select = false }),
["<c-n>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then elseif vim.fn["vsnip#available"](1) == 1 then
@ -290,7 +295,7 @@ return {
end end
end, { "i", "s" }), end, { "i", "s" }),
["<n-p>"] = cmp.mapping(function() ["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then elseif vim.fn["vsnip#jumpable"](-1) == 1 then
@ -304,13 +309,14 @@ return {
entries = { name = 'wildmenu', separator = '|' } entries = { name = 'wildmenu', separator = '|' }
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'buffer' }, -- { name = 'buffer' },
{ name = 'cmdline' }
}), }),
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({ select = false }), -- ['<CR>'] = cmp.mapping.confirm({ select = false }),
["<c-n>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then elseif vim.fn["vsnip#available"](1) == 1 then
@ -322,7 +328,7 @@ return {
end end
end, { "i", "s" }), end, { "i", "s" }),
["<n-p>"] = cmp.mapping(function() ["<S-tab>"] = cmp.mapping(function()
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then elseif vim.fn["vsnip#jumpable"](-1) == 1 then

11
lua/plugs/yaml.lua Normal file
View File

@ -0,0 +1,11 @@
return {
settings = {
yaml = {
schemas = {
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
["../path/relative/to/file.yml"] = "/.github/workflows/*",
["/path/from/root/of/project"] = "/.github/workflows/*",
},
},
}
}