266 lines
6.2 KiB
Lua
266 lines
6.2 KiB
Lua
return {{
|
|
"neovim/nvim-lspconfig",
|
|
dependencies={
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
},
|
|
config=function()
|
|
local servers = { 'lua_ls', 'vimls', 'bashls', 'vale_ls', 'gopls' }
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
for _, lsp in ipairs(servers) do
|
|
require('lspconfig')[lsp].setup {
|
|
capabilities = capabilities,
|
|
}
|
|
end
|
|
|
|
-- Use LspAttach autocommand to only map the following keys
|
|
-- after the language server attaches to the current buffer
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
|
callback = function(ev)
|
|
-- Enable completion triggered by <c-x><c-o>
|
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
|
|
|
-- Buffer local mappings.
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
local opts = { buffer = ev.buf }
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
|
vim.keymap.set('n', '<space>wl', function()
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
end, opts)
|
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
|
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
|
--vim.keymap.set('n', '<space>f', function()
|
|
-- vim.lsp.buf.format { async = true }
|
|
--end, opts)
|
|
end,
|
|
})
|
|
|
|
end,
|
|
},{
|
|
"L3MON4D3/LuaSnip",
|
|
dependencies={
|
|
"saadparwaiz1/cmp_luasnip",
|
|
--"rafamadriz/friendly-snippets"
|
|
},
|
|
config=function ()
|
|
|
|
local ls = require("luasnip")
|
|
-- some shorthands...
|
|
local s = ls.snippet
|
|
--local sn = ls.snippet_node
|
|
local t = ls.text_node
|
|
local i = ls.insert_node
|
|
--local f = ls.function_node
|
|
local c = ls.choice_node
|
|
--local d = ls.dynamic_node
|
|
--local r = ls.restore_node
|
|
local fmt = require("luasnip.extras.fmt").fmt
|
|
local p = require("luasnip.extras").partial
|
|
|
|
ls.setup({
|
|
update_events = {"TextChanged", "TextChangedI"}
|
|
})
|
|
|
|
ls.add_snippets( "all", {
|
|
s("date", { p(os.date, "%Y-%m-%d") }),
|
|
s("time", { p(os.date, "%H:%M:%S") }),
|
|
})
|
|
|
|
ls.add_snippets( "markdown", {
|
|
s("finding", fmt([[
|
|
header{}
|
|
|
|
title{}
|
|
|
|
matxix{}
|
|
|
|
instances{}
|
|
|
|
desc{}
|
|
|
|
techdetails{}
|
|
|
|
recommendation{}
|
|
]],{
|
|
i(1),
|
|
i(2),
|
|
i(3),
|
|
i(4),
|
|
i(5),
|
|
i(6),
|
|
i(7),
|
|
})),
|
|
s("header", fmt([[
|
|
---
|
|
impact: {}
|
|
likelihood: {}
|
|
rootCause: {}
|
|
source: NEW
|
|
---
|
|
|
|
]], {
|
|
c(1, { t("Critical"),t("High"),t("Medium"),t("Low"),t("Informational") }),
|
|
c(2, { t("Critical"),t("High"),t("Medium"),t("Low"),t("Informational") }),
|
|
i(3, "TODO")
|
|
})),
|
|
s("title", {
|
|
t("## \\findingId "),
|
|
i(1, "title"),
|
|
|
|
}),
|
|
s("title", {
|
|
t("## \\findingId "),
|
|
i(1, "title"),
|
|
|
|
}),
|
|
s("matrix", fmt([[
|
|
```{{.table .transpose align=xX}}
|
|
Impact: \fmImpact
|
|
Likelihood: \fmLikelihood
|
|
Overall Risk: \fmRisk
|
|
Root Cause: \rootcause
|
|
Complexity to Fix: {}
|
|
Finding Status: {}
|
|
```
|
|
]], {
|
|
c(1, { t("Easy"),t("Medium"),t("Hard") }),
|
|
c(2, { t("Verified and Evidenced"),t("Tool Output"),i(nil,"Something Else") }),
|
|
}
|
|
)),
|
|
s("instances", fmt([[
|
|
### Instances
|
|
|
|
```{{.table align=xX}}
|
|
- Instance: fill out{}
|
|
Details: fill out
|
|
```
|
|
|
|
]], {
|
|
t("todo")
|
|
}
|
|
)),
|
|
s("sf", fmt([[
|
|
:::indent
|
|
|
|
#### {} ({},{})
|
|
|
|
{}
|
|
|
|
##### Technical Details
|
|
|
|
{}
|
|
|
|
##### Recommendation
|
|
|
|
{}
|
|
|
|
:::
|
|
{}
|
|
]],{
|
|
i(1),
|
|
c(2, { t("\\Informational"),t("\\Low"),t("\\Medium"),t("\\High"),t("\\Critical") }),
|
|
c(3, { t("\\Informational"),t("\\Low"),t("\\Medium"),t("\\High"),t("\\Critical") }),
|
|
i(4),
|
|
i(5),
|
|
i(6),
|
|
i(0),
|
|
})),
|
|
s("moreinfo", fmt([[
|
|
For additional information regarding this issue, please read:
|
|
|
|
* <{}>
|
|
]],{
|
|
i(1)
|
|
})),
|
|
})
|
|
end,
|
|
keys = {
|
|
{ "<C-j>", function ()
|
|
local ls = require("luasnip")
|
|
if ( ls.expand_or_jumpable() ) then
|
|
return ls.expand_or_jump()
|
|
end
|
|
end, mode = {"i","s"}
|
|
},
|
|
{ "<C-k>", function ()
|
|
local ls = require("luasnip")
|
|
ls.jump(-1)
|
|
end, mode = {"i","s"}
|
|
},
|
|
{ "<C-l>", function ()
|
|
local ls = require("luasnip")
|
|
if ls.choice_active() then
|
|
ls.change_choice(1)
|
|
end
|
|
end, mode = {"i","s"}
|
|
},
|
|
}
|
|
},{
|
|
"hrsh7th/nvim-cmp",
|
|
dependencies={
|
|
"neovim/nvim-lspconfig",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"hrsh7th/cmp-nvim-lua",
|
|
"hrsh7th/cmp-cmdline",
|
|
"onsails/lspkind.nvim"
|
|
},
|
|
opts=function()
|
|
local cmp = require("cmp")
|
|
local lspkind = require('lspkind')
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
|
|
return {
|
|
snippet = {
|
|
-- REQUIRED - you must specify a snippet engine
|
|
expand = function(args)
|
|
--vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
|
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
|
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
|
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(),
|
|
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = "nvim_lua" },
|
|
{ name = "nvim_lsp" },
|
|
{ name = "kb_tags" },
|
|
{ name = "report_tool" },
|
|
{ name = "luasnip" },
|
|
{ name = "path" },
|
|
{ name = "buffer" }
|
|
}),
|
|
formatting = {
|
|
format = lspkind.cmp_format({
|
|
mode = 'symbol_text',
|
|
maxwidth = 100,
|
|
ellipsis_char = '…',
|
|
menu = {
|
|
nvim_lsp = "[lsp]",
|
|
kb_tags = "[tags]",
|
|
luasnip = "[snip]",
|
|
nvim_lua = "[nvim]",
|
|
path = "[path]",
|
|
buffer = "[buf]",
|
|
}
|
|
})
|
|
}
|
|
}
|
|
end
|
|
}}
|
|
|