nvim stuff
This commit is contained in:
parent
76e9e832ce
commit
5b44925a9a
29 changed files with 775 additions and 171 deletions
3
bin/.bin/nessus-extract-ips
Executable file
3
bin/.bin/nessus-extract-ips
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
xq -r '[ .NessusClientData_v2.Report.ReportHost | if (. | type == "array") then .[] else . end | (.ReportItem[] + {ip:."@name"})] | .[] | select(."@pluginName" == "'"$1"'") | .ip'
|
||||
60
nvim/.config/nvim/after/plugin/rt-cmp.lua
Normal file
60
nvim/.config/nvim/after/plugin/rt-cmp.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
local Job = require'plenary.job'
|
||||
|
||||
local source = {}
|
||||
|
||||
source.new = function()
|
||||
local self = setmetatable({}, { __index = source })
|
||||
return self
|
||||
end
|
||||
|
||||
function source:is_available()
|
||||
return true
|
||||
end
|
||||
|
||||
function source:get_debug_name()
|
||||
return 'report_tool'
|
||||
end
|
||||
|
||||
function source:complete(params, callback)
|
||||
if (params.context.cursor_before_line:find('^impact:') or params.context.cursor_before_line:find('^likelihood:') ) then
|
||||
callback({
|
||||
{ label = "Critical" },
|
||||
{ label = "High" },
|
||||
{ label = "Medium" },
|
||||
{ label = "Low" },
|
||||
{ label = "Informational" },
|
||||
})
|
||||
end
|
||||
|
||||
if (params.context.cursor_before_line:find('^Finding Status:')) then
|
||||
callback({
|
||||
{ label = "Verified and Evidenced" },
|
||||
{ label = "Tool Output" },
|
||||
})
|
||||
end
|
||||
|
||||
if string.match(params.context.cursor_before_line, "rootCause: ") then
|
||||
Job:new({
|
||||
command = 'rt',
|
||||
args = { '--debugfunction', 'printRootCauses' },
|
||||
on_exit = function(response, _)
|
||||
local listOfEntries={}
|
||||
for _,rootcause in ipairs(response:result()) do
|
||||
table.insert(listOfEntries, { label = rootcause })
|
||||
end
|
||||
callback(listOfEntries)
|
||||
end,
|
||||
}):start()
|
||||
end
|
||||
end
|
||||
|
||||
function source:resolve(completion_item, callback)
|
||||
callback(completion_item)
|
||||
end
|
||||
|
||||
function source:execute(completion_item, callback)
|
||||
callback(completion_item)
|
||||
end
|
||||
|
||||
|
||||
require('cmp').register_source("report_tool", source.new())
|
||||
45
nvim/.config/nvim/after/plugin/tags.lua
Normal file
45
nvim/.config/nvim/after/plugin/tags.lua
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
local Job = require'plenary.job'
|
||||
|
||||
local source = {}
|
||||
|
||||
source.new = function()
|
||||
local self = setmetatable({}, { __index = source })
|
||||
return self
|
||||
end
|
||||
|
||||
function source:is_available()
|
||||
return true
|
||||
end
|
||||
|
||||
function source:get_debug_name()
|
||||
return 'kb_tags'
|
||||
end
|
||||
|
||||
|
||||
function source:complete(params, callback)
|
||||
if string.match(params.context.cursor_before_line, "%s*-%s*") then
|
||||
Job:new({
|
||||
command = 'kb',
|
||||
args = { 'list-tags', '--noheader' },
|
||||
on_exit = function(response, _)
|
||||
local listOfEntries={}
|
||||
for _,tagwithcount in ipairs(response:result()) do
|
||||
local tag = string.match(tagwithcount, "(.-)%s%s")
|
||||
table.insert(listOfEntries, { label = tag })
|
||||
end
|
||||
callback(listOfEntries)
|
||||
end,
|
||||
}):start()
|
||||
end
|
||||
end
|
||||
|
||||
function source:resolve(completion_item, callback)
|
||||
callback(completion_item)
|
||||
end
|
||||
|
||||
function source:execute(completion_item, callback)
|
||||
callback(completion_item)
|
||||
end
|
||||
|
||||
|
||||
require('cmp').register_source("kb_tags", source.new())
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
function! mine#functions#text() abort
|
||||
" set spellchecking
|
||||
set spell
|
||||
set spelllang=en_gb
|
||||
|
||||
" Add undo points when this punctuation is added
|
||||
inoremap <buffer> ! !<C-g>u
|
||||
|
|
@ -55,3 +56,16 @@ function! mine#functions#languagetool() abort
|
|||
let &l:makeprg = oldmakeprg
|
||||
let &l:makeprg = olderrformat
|
||||
endfunction
|
||||
|
||||
function! mine#functions#vale() abort
|
||||
let oldmakeprg = &l:makeprg
|
||||
let olderrformat = &l:errorformat
|
||||
" set new value of makeprg and call the function
|
||||
set makeprg=vale\ --filter='.Level\ in\ [\"error\"\,\ \"warning\"]'\ --output\ line\ \"%:p:h\"
|
||||
let &l:errorformat = '%f:%l:%c:%m'
|
||||
make
|
||||
copen
|
||||
" set makeprg back to old value
|
||||
let &l:makeprg = oldmakeprg
|
||||
let &l:makeprg = olderrformat
|
||||
endfunction
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
" Options:
|
||||
let php_noindent_switch=0 " set this to '1' to not try to indent switch/case statements
|
||||
set sw=3 " default shiftwidth of 3 spaces
|
||||
#set sw=3 " default shiftwidth of 3 spaces
|
||||
|
||||
|
||||
if exists("b:did_indent")
|
||||
|
|
@ -2,10 +2,6 @@
|
|||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
vim.cmd([[
|
||||
syntax on
|
||||
filetype indent plugin on
|
||||
]])
|
||||
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
|
|
@ -21,63 +17,3 @@ end
|
|||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup("plugins")
|
||||
-- require("lazy").setup({ {
|
||||
-- "ellisonleao/gruvbox.nvim",
|
||||
-- lazy = false,
|
||||
-- priority=1000
|
||||
-- },{
|
||||
-- "nvim-treesitter/nvim-treesitter",
|
||||
-- build = ":TSUpdate"
|
||||
-- }
|
||||
-- })
|
||||
--
|
||||
vim.cmd("colorscheme gruvbox")
|
||||
|
||||
vim.cmd([[
|
||||
|
||||
|
||||
"if has('packages')
|
||||
" packadd! AnsiEsc.vim
|
||||
" packadd! fzf.vim
|
||||
" packadd! gruvbox
|
||||
" packadd! gruvbox-baby
|
||||
" packadd! lexima.vim
|
||||
" packadd! loupe
|
||||
" packadd! ultisnips
|
||||
" packadd! vim-fugitive
|
||||
" packadd! vim-json
|
||||
" packadd! vim-less
|
||||
" packadd! vim-projectionist
|
||||
" packadd! vim-repeat
|
||||
" packadd! vim-snippets
|
||||
" packadd! vim-surround
|
||||
" packadd! vim-tridactyl
|
||||
" packadd! vim-vinegar
|
||||
" packadd! vim-openscad
|
||||
" if has('nvim')
|
||||
" packadd! deoplete.nvim
|
||||
" packadd! deoplete-abook
|
||||
" packadd! deoplete-lsp
|
||||
" packadd! deoplete-notmuch
|
||||
" packadd! firenvim
|
||||
" packadd! nvim-treesitter
|
||||
" " packadd! nvim-biscuits
|
||||
" lua <<EOF
|
||||
" if ( vim.lsp ~= nil ) then
|
||||
" vim.cmd "packadd! nvim-lspconfig"
|
||||
" end
|
||||
"EOF
|
||||
" endif
|
||||
"endif
|
||||
|
||||
" Enables filetype detection as well as filetype specific indent rules and plugins
|
||||
"filetype indent plugin on
|
||||
" Enables filetype specific syntaxs
|
||||
|
||||
"syntax on
|
||||
|
||||
""let g:UltiSnipsExpandTrigger="<tab>"
|
||||
""let g:UltiSnipsJumpForwardTrigger="<tab>"
|
||||
""let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
|
||||
|
||||
]])
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ return {{
|
|||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config=function()
|
||||
local servers = { 'lua_ls', 'vimls', 'bashls', 'vale_ls' }
|
||||
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 {
|
||||
|
|
@ -12,7 +12,6 @@ return {{
|
|||
}
|
||||
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', {
|
||||
|
|
@ -45,35 +44,179 @@ return {{
|
|||
})
|
||||
|
||||
end,
|
||||
--},{
|
||||
-- "L3MON4D3/LuaSnip",
|
||||
-- dependencies={
|
||||
-- "saadparwaiz1/cmp_luasnip",
|
||||
-- "rafamadriz/friendly-snippets"
|
||||
-- },
|
||||
-- config=function ()
|
||||
-- require("luasnip.loaders.from_vscode").lazy_load()
|
||||
-- end,
|
||||
-- keys = {
|
||||
-- { "<tab>", function ()
|
||||
-- return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
|
||||
-- end, expr = true, silent = true, mode = "i"
|
||||
-- },
|
||||
-- { "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
|
||||
-- { "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
|
||||
-- }
|
||||
},{
|
||||
"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",
|
||||
--"L3MON4D3/LuaSnip",
|
||||
"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 {
|
||||
|
|
@ -91,17 +234,33 @@ return {{
|
|||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<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
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,27 @@ return {{
|
|||
operators = false,
|
||||
folds = true,
|
||||
}
|
||||
},
|
||||
init = function()
|
||||
--vim.cmd.colorscheme 'gruvbox'
|
||||
end
|
||||
},{
|
||||
"rebelot/kanagawa.nvim",
|
||||
lazy = false,
|
||||
priority=1000,
|
||||
opts={
|
||||
terminal_colors = true,
|
||||
italic = {
|
||||
strings = false,
|
||||
emphasis = false,
|
||||
comments = true,
|
||||
operators = false,
|
||||
folds = true,
|
||||
}
|
||||
},
|
||||
init = function()
|
||||
vim.cmd.colorscheme 'kanagawa-dragon'
|
||||
end
|
||||
}}
|
||||
|
||||
-- Colourscheme settings
|
||||
4
nvim/.config/nvim/lua/plugins/git.lua
Normal file
4
nvim/.config/nvim/lua/plugins/git.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
{ "tpope/vim-fugitive" },
|
||||
{ "lewis6991/gitsigns.nvim", opts={} }
|
||||
}
|
||||
34
nvim/.config/nvim/lua/plugins/image.lua
Normal file
34
nvim/.config/nvim/lua/plugins/image.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
return {{
|
||||
"3rd/image.nvim",
|
||||
branch = "feat/toggle-rendering",
|
||||
dependencies = {
|
||||
{
|
||||
"vhyrro/luarocks.nvim",
|
||||
opts = {
|
||||
rocks = { "magick" }
|
||||
}
|
||||
}
|
||||
},
|
||||
config = function()
|
||||
local image = require("image")
|
||||
image.setup({
|
||||
backend = "ueberzug",
|
||||
integrations = {
|
||||
markdown = {
|
||||
enabled = true,
|
||||
clear_in_insert_mode = false,
|
||||
download_remote_images = true,
|
||||
only_render_image_at_cursor = false,
|
||||
filetypes = { "markdown", "vimwiki", "md" }, -- markdown extensions (ie. quarto) can go here
|
||||
},
|
||||
}
|
||||
})
|
||||
vim.keymap.set("n", "<leader>ti", function()
|
||||
if image.is_enabled() then
|
||||
image.disable()
|
||||
else
|
||||
image.enable()
|
||||
end
|
||||
end, {})
|
||||
end,
|
||||
}}
|
||||
17
nvim/.config/nvim/lua/plugins/img-paste.lua
Normal file
17
nvim/.config/nvim/lua/plugins/img-paste.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
return {
|
||||
'dfendr/clipboard-image.nvim',
|
||||
config = function()
|
||||
require("clipboard-image").setup {
|
||||
default = {
|
||||
img_dir = {"%:p:h","images"},
|
||||
img_dir_txt = "./images",
|
||||
img_name = function() return os.date('%Y-%m-%d-%H-%M-%S') end, -- Example result: "2021-04-13-10-04-18"
|
||||
affix = "<\n %s\n>" -- Multi lines affix
|
||||
},
|
||||
markdown = {
|
||||
affix = ""
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
}
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
return { {
|
||||
"tpope/vim-fugitive"
|
||||
} }
|
||||
return {
|
||||
{ "numToStr/Comment.nvim", opts={} }
|
||||
}
|
||||
-- Look into https://github.com/Exafunction/codeium.vim
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
3
nvim/.config/nvim/lua/plugins/jq-playground.lua
Normal file
3
nvim/.config/nvim/lua/plugins/jq-playground.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
return {
|
||||
{ 'yochem/jq-playground.nvim' }
|
||||
}
|
||||
45
nvim/.config/nvim/lua/plugins/lualine.lua
Normal file
45
nvim/.config/nvim/lua/plugins/lualine.lua
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
lazy = false,
|
||||
opts = {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = { left = '\u{E0B5}', right = '\u{E0B7}'},
|
||||
section_separators = { left = '\u{E0B4}', right = '\u{E0B6}'},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
}
|
||||
}
|
||||
27
nvim/.config/nvim/lua/plugins/oil.lua
Normal file
27
nvim/.config/nvim/lua/plugins/oil.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
return {
|
||||
'stevearc/oil.nvim',
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("oil").setup {
|
||||
columns = { "icon" },
|
||||
delete_to_trash = true,
|
||||
keymaps = {
|
||||
["<C-h>"] = false,
|
||||
},
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
}
|
||||
|
||||
-- Open parent directory in current window
|
||||
vim.keymap.set("n", "-", function()
|
||||
local oil = require('oil')
|
||||
oil.open()
|
||||
|
||||
require('oil.util').run_after_load(0, function()
|
||||
oil.open_preview()
|
||||
end)
|
||||
end, { desc = "Open parent directory" })
|
||||
|
||||
end
|
||||
}
|
||||
57
nvim/.config/nvim/lua/plugins/ollama.lua
Normal file
57
nvim/.config/nvim/lua/plugins/ollama.lua
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
descriptionPrompt="You are a security proffessional writing to a technical audience. Don't introduce yourself. Keep your answer brief, to a couple of paragraphs if possible. Avoid lists and bullets. Avoid using abreviations. Write in UK english."
|
||||
return {
|
||||
"nomnivore/ollama.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
|
||||
-- All the user commands added by the plugin
|
||||
cmd = { "Ollama", "OllamaModel", "OllamaServe", "OllamaServeStop" },
|
||||
|
||||
keys = {
|
||||
-- Sample keybind for prompt menu. Note that the <c-u> is important for selections to work properly.
|
||||
{
|
||||
"<leader>oo",
|
||||
":<c-u>lua require('ollama').prompt()<cr>",
|
||||
desc = "ollama prompt",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
|
||||
-- Sample keybind for direct prompting. Note that the <c-u> is important for selections to work properly.
|
||||
{
|
||||
"<leader>oG",
|
||||
":<c-u>lua require('ollama').prompt('Generate_Code')<cr>",
|
||||
desc = "ollama Generate Code",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
},
|
||||
|
||||
---@type Ollama.Config
|
||||
opts = {
|
||||
-- your configuration overrides
|
||||
model = "llama3.2:latest",
|
||||
url = "http://127.0.0.1:11434",
|
||||
serve = {
|
||||
on_start = false,
|
||||
command = "ollama",
|
||||
args = { "serve" },
|
||||
stop_command = "pkill",
|
||||
stop_args = { "-SIGTERM", "ollama" },
|
||||
},
|
||||
-- View the actual default prompts in ./lua/ollama/prompts.lua
|
||||
prompts = {
|
||||
ReWrite_Technical_Description = {
|
||||
prompt= descriptionPrompt .. "\n\nRewrite the following making it easier to understand.\n\n$sel",
|
||||
action = "display"
|
||||
},
|
||||
Write_Technical_Description = {
|
||||
prompt= descriptionPrompt .. "\n\nPlease explain what $input is, and why it is bad. ",
|
||||
input_label = "for:"
|
||||
},
|
||||
Write_Technical_Description_From_Details = {
|
||||
prompt= descriptionPrompt .. "Based on the following evidence, write a description of the security issue:\n\n$sel",
|
||||
action = "display"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
nvim/.config/nvim/lua/plugins/query editor
Normal file
14
nvim/.config/nvim/lua/plugins/query editor
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
reduce .findings[] as $finding( []; . + [
|
||||
if $finding | has("subIssues") then
|
||||
$finding.subIssues[] | if . | has("shortSubIssues") then
|
||||
(.shortSubIssues[] | {title: .title, impact: .impact, likelihood: .likelihood})
|
||||
else
|
||||
{title: .title, impact: .impact, likelihood: .likelihood}
|
||||
end
|
||||
elif $finding | has("shortSubIssues") then
|
||||
($finding.shortSubIssues[] | {title: .title, impact: .impact, likelihood: .likelihood})
|
||||
else
|
||||
{title: $finding.title, impact: $finding.impact, likelihood: $finding.likelihood}
|
||||
end] ) |
|
||||
group_by(.likelihood) | map({(.[0].likelihood): .}) | add |
|
||||
map_values(. | group_by(.impact) | map({(.[0].impact): (. | length)}) | add)
|
||||
17
nvim/.config/nvim/lua/plugins/test.md
Normal file
17
nvim/.config/nvim/lua/plugins/test.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
:::indent
|
||||
|
||||
#### Something (\High,\Low)
|
||||
|
||||
some description
|
||||
|
||||
##### Technical Details
|
||||
|
||||
something
|
||||
|
||||
##### Recommendation
|
||||
|
||||
something
|
||||
|
||||
:::
|
||||
something
|
||||
130
nvim/.config/nvim/plugin/decoder.lua.tmp
Normal file
130
nvim/.config/nvim/plugin/decoder.lua.tmp
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
local api = vim.api
|
||||
local uv = vim.loop
|
||||
|
||||
local function decode_base64(input)
|
||||
vim.print(input)
|
||||
return vim.fn.system('echo ' .. input .. ' | base64 --decode'):gsub("\n","")
|
||||
end
|
||||
|
||||
local function encode_base64(input)
|
||||
return vim.fn.system('echo ' .. input .. ' | base64'):gsub("\n","")
|
||||
end
|
||||
|
||||
local function decode_hex(input)
|
||||
return vim.fn.system('echo ' .. input .. ' | xxd -r -p'):gsub("\n","")
|
||||
end
|
||||
|
||||
local function encode_hex(input)
|
||||
return vim.fn.system('echo -n ' .. input .. ' | xxd -p'):gsub("\n","")
|
||||
end
|
||||
|
||||
local function decode_url(input)
|
||||
return vim.fn.system('echo ' .. input .. ' | python3 -c "import urllib.parse; print(urllib.parse.unquote(input))"'):gsub("\n","")
|
||||
end
|
||||
|
||||
local function encode_url(input)
|
||||
return vim.fn.system('echo ' .. input .. ' | python3 -c "import urllib.parse; print(urllib.parse.quote(input))"'):gsub("\n","")
|
||||
end
|
||||
|
||||
local function get_text_object(object)
|
||||
-- Get the text object under the cursor
|
||||
local start_pos = api.nvim_win_get_cursor(0)
|
||||
local line = api.nvim_get_current_line()
|
||||
|
||||
local start_idx, end_idx
|
||||
if object == "iw" then
|
||||
start_idx, end_idx = line:find("%S+")
|
||||
elseif object == "i(" then
|
||||
start_idx, end_idx = line:find("%b()")
|
||||
elseif object == "i{" then
|
||||
start_idx, end_idx = line:find("%b{}")
|
||||
elseif object == "i[" then
|
||||
start_idx, end_idx = line:find("%b[]")
|
||||
else
|
||||
return nil
|
||||
end
|
||||
|
||||
if start_idx and end_idx then
|
||||
return line:sub(start_idx, end_idx)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function open_popup(object)
|
||||
local selected_text = get_text_object(object)
|
||||
|
||||
if not selected_text then
|
||||
print("No text object found!")
|
||||
return
|
||||
end
|
||||
|
||||
-- Prompt user for encoding/decoding type
|
||||
local choice = vim.fn.input("Choose encoding/decoding (base64, hex, url): ")
|
||||
|
||||
local decoded_text
|
||||
if choice == "base64" then
|
||||
decoded_text = decode_base64(selected_text)
|
||||
elseif choice == "hex" then
|
||||
decoded_text = decode_hex(selected_text)
|
||||
elseif choice == "url" then
|
||||
decoded_text = decode_url(selected_text)
|
||||
else
|
||||
print("Invalid choice!")
|
||||
return
|
||||
end
|
||||
|
||||
-- Create a popup window
|
||||
local popup_buf = api.nvim_create_buf(false, true)
|
||||
local width = 50
|
||||
local height = 10
|
||||
local opts = {
|
||||
style = 'minimal',
|
||||
relative = 'editor',
|
||||
width = width,
|
||||
height = height,
|
||||
row = (api.nvim_get_option('lines') - height) / 2,
|
||||
col = (api.nvim_get_option('columns') - width) / 2,
|
||||
}
|
||||
|
||||
-- Set the decoded text in the popup buffer
|
||||
api.nvim_buf_set_lines(popup_buf, 0, -1, false, { decoded_text })
|
||||
|
||||
-- Open the popup window
|
||||
local popup_win = api.nvim_open_win(popup_buf, true, opts)
|
||||
|
||||
-- Set up a buffer-local command to save changes
|
||||
api.nvim_buf_set_keymap(popup_buf, 'n', '<C-s>', ':lua save_and_replace("' .. selected_text .. '", "' .. choice .. '", ' .. popup_buf .. ')<CR>', { noremap = true, silent = true })
|
||||
end
|
||||
|
||||
function save_and_replace(original_text, choice, popup_buf)
|
||||
local new_lines = api.nvim_buf_get_lines(popup_buf, 0, -1, false)
|
||||
local new_text = table.concat(new_lines, "\n")
|
||||
local encoded_text
|
||||
|
||||
if choice == "base64" then
|
||||
encoded_text = encode_base64(new_text)
|
||||
elseif choice == "hex" then
|
||||
encoded_text = encode_hex(new_text)
|
||||
elseif choice == "url" then
|
||||
encoded_text = encode_url(new_text)
|
||||
else
|
||||
print("Invalid choice!")
|
||||
return
|
||||
end
|
||||
|
||||
-- Replace the original text in the current line
|
||||
local cursor_pos = api.nvim_win_get_cursor(0)
|
||||
local line = api.nvim_get_current_line()
|
||||
local new_line = line:gsub(original_text, encoded_text, 1)
|
||||
api.nvim_set_current_line(new_line)
|
||||
|
||||
-- Close the popup
|
||||
api.nvim_win_close(popup_buf, true)
|
||||
end
|
||||
|
||||
|
||||
-- Bind the function to key mappings for text objects
|
||||
vim.api.nvim_set_keymap('n', '<leader>diw', ':lua open_popup("iw")<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>di(', ':lua open_popup("i(")<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>di{', ':lua open_popup("i{")<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>di[', ':lua open_popup("i[")<CR>', { noremap = true, silent = true })
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
" If we aren't in nvim, exit
|
||||
if !has('nvim')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Make deoplete start at startup
|
||||
let g:deoplete#enable_at_startup = 1
|
||||
|
||||
" Closes the preview window once a completion is done
|
||||
autocmd CompleteDone * silent! pclose!
|
||||
79
nvim/.config/nvim/plugin/httprequest.lua
Normal file
79
nvim/.config/nvim/plugin/httprequest.lua
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
local http = require("socket.http")
|
||||
local ltn12 = require("ltn12")
|
||||
|
||||
|
||||
local response_buf = nil
|
||||
|
||||
local function make_http_request()
|
||||
-- Get the current buffer content
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local request_lines = vim.api.nvim_buf_get_lines(current_buf, 0, -1, false)
|
||||
local request = table.concat(request_lines, "\n")
|
||||
|
||||
-- Split the request into lines
|
||||
local request_headers = {}
|
||||
for line in request:gmatch("[^\r\n]+") do
|
||||
table.insert(request_headers, line)
|
||||
end
|
||||
|
||||
|
||||
-- Extract the request method, URL, and headers
|
||||
local method, url = request_headers[1]:match("^(%S+)%s+(%S+)")
|
||||
local headers = {}
|
||||
for i = 2, #request_headers do
|
||||
local header_line = request_headers[i]
|
||||
if header_line == "" then break end
|
||||
local key, value = header_line:match("^(%S+):%s*(.+)$")
|
||||
if key and value then
|
||||
headers[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
-- Prepare the response
|
||||
local response_body = {}
|
||||
local res, code, response_headers, status = http.request{
|
||||
method = method,
|
||||
url = url,
|
||||
headers = headers,
|
||||
sink = ltn12.sink.table(response_body)
|
||||
}
|
||||
|
||||
|
||||
local response_lines = {}
|
||||
|
||||
|
||||
table.insert(response_lines, status)
|
||||
for k, v in pairs(response_headers) do
|
||||
table.insert(response_lines, k .. ": " .. v)
|
||||
end
|
||||
table.insert(response_lines, "") -- Add a blank line for separation
|
||||
|
||||
for _, line in ipairs(response_body) do
|
||||
for l in line:gmatch("[^\n]+") do
|
||||
table.insert(response_lines, l)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Check if the response buffer already exists
|
||||
if response_buf == nil then
|
||||
-- Create a new buffer for the response
|
||||
response_buf = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
-- Open the new buffer in a split to the right
|
||||
vim.api.nvim_command("vsplit")
|
||||
vim.api.nvim_set_current_buf(response_buf)
|
||||
|
||||
-- Optionally set the buffer name
|
||||
vim.api.nvim_buf_set_name(response_buf, "HTTP Response: " .. url)
|
||||
--else
|
||||
-- -- If the buffer exists, set it as the current buffer
|
||||
-- vim.api.nvim_set_current_buf(response_buf)
|
||||
end
|
||||
|
||||
|
||||
vim.api.nvim_buf_set_lines(response_buf, 0, -1, false, response_lines)
|
||||
end
|
||||
|
||||
-- Create a command to run the function
|
||||
vim.api.nvim_create_user_command('HttpRequest', make_http_request, {})
|
||||
|
|
@ -33,7 +33,7 @@ end
|
|||
-- `] - go to the end of the last changed word
|
||||
-- a - enter insert mode
|
||||
-- <c-g>u - break undo sequence (new change)
|
||||
vim.keymap.set('i', '<c-l>','<c-g>u<Esc>[s1z=`]a<c-g>u', {desc="Fix previous spelling mistake"})
|
||||
vim.keymap.set('i', '<c-y>','<c-g>u<Esc>[s1z=`]a<c-g>u', {desc="Fix previous spelling mistake"})
|
||||
|
||||
-- Do Shebang line
|
||||
-- <Esc> - go into normal mode
|
||||
|
|
@ -42,7 +42,7 @@ vim.keymap.set('i', '<c-l>','<c-g>u<Esc>[s1z=`]a<c-g>u', {desc="Fix previous spe
|
|||
-- <bar> - used to seperate commands
|
||||
-- filetype detect - attempt to detect filetype again
|
||||
-- :nohlsearch - un-hilight the search pattern
|
||||
vim.keymap.set('i', '<C-y>', '<Esc>:silent s/^/#!\\/usr\\/bin\\/env / <bar> filetype detect<cr>:nohlsearch<cr>o', {desc="do shebang line"})
|
||||
--vim.keymap.set('i', '<C-y>', '<Esc>:silent s/^/#!\\/usr\\/bin\\/env / <bar> filetype detect<cr>:nohlsearch<cr>o', {desc="do shebang line"})
|
||||
|
||||
|
||||
-- Makes delete key work properly in insert mode
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
"let g:OmniSharp_highlighting = 0
|
||||
let g:OmniSharp_selector_ui = 'fzf'
|
||||
|
||||
augroup omnisharp_commands
|
||||
autocmd!
|
||||
|
||||
" Show type information automatically when the cursor stops moving.
|
||||
" Note that the type is echoed to the Vim command line, and will overwrite
|
||||
" any other messages in this space including e.g. ALE linting messages.
|
||||
"autocmd CursorHold *.cs OmniSharpTypeLookup
|
||||
|
||||
" The following commands are contextual, based on the cursor position.
|
||||
autocmd FileType cs nmap <silent> <buffer> <c-]> <Plug>(omnisharp_go_to_definition)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osfi <Plug>(omnisharp_find_implementations)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>ospd <Plug>(omnisharp_preview_definition)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>ospi <Plug>(omnisharp_preview_implementations)
|
||||
autocmd FileType cs nmap <silent> <buffer> K <Plug>(omnisharp_type_lookup)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osd <Plug>(omnisharp_documentation)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osfs <Plug>(omnisharp_find_symbol)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osfx <Plug>(omnisharp_fix_usings)
|
||||
|
||||
" Navigate up and down by method/property/field
|
||||
autocmd FileType cs nmap <silent> <buffer> [[ <Plug>(omnisharp_navigate_up)
|
||||
autocmd FileType cs nmap <silent> <buffer> ]] <Plug>(omnisharp_navigate_down)
|
||||
" Find all code errors/warnings for the current solution and populate the quickfix window
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osgcc <Plug>(omnisharp_global_code_check)
|
||||
" Contextual code actions (uses fzf, vim-clap, CtrlP or unite.vim selector when available)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osca <Plug>(omnisharp_code_actions)
|
||||
autocmd FileType cs xmap <silent> <buffer> <Leader>osca <Plug>(omnisharp_code_actions)
|
||||
" Repeat the last code action performed (does not use a selector)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>os. <Plug>(omnisharp_code_action_repeat)
|
||||
autocmd FileType cs xmap <silent> <buffer> <Leader>os. <Plug>(omnisharp_code_action_repeat)
|
||||
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>os= <Plug>(omnisharp_code_format)
|
||||
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osnm <Plug>(omnisharp_rename)
|
||||
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osre <Plug>(omnisharp_restart_server)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>osst <Plug>(omnisharp_start_server)
|
||||
autocmd FileType cs nmap <silent> <buffer> <Leader>ossp <Plug>(omnisharp_stop_server)
|
||||
augroup END
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
let g:projectionist_heuristics = {
|
||||
\'*': {
|
||||
\ 'src/*.c': {
|
||||
\ 'alternate': [
|
||||
\ 'src/{}.h',
|
||||
\ 'tests/{}.test.c'
|
||||
\ ],
|
||||
\ 'type': 'source'
|
||||
\ },
|
||||
\ 'src/*.h': {
|
||||
\ 'alternate': [
|
||||
\ 'tests/{}.test.c',
|
||||
\ 'src/{}.c'
|
||||
\ ],
|
||||
\ 'type': 'header'
|
||||
\ },
|
||||
\ 'tests/*.test.c': {
|
||||
\ 'alternate': [
|
||||
\ 'src/{}.c',
|
||||
\ 'src/{}.h',
|
||||
\ ],
|
||||
\ 'type': 'test'
|
||||
\ },
|
||||
\ }
|
||||
\}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
-- Set spellcheck language to english
|
||||
vim.opt.spelllang=en_gb
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ vim.opt.autoindent=true
|
|||
vim.opt.smartindent=true
|
||||
vim.opt.shiftwidth=4
|
||||
vim.opt.tabstop=4
|
||||
vim.opt.expandtab=false
|
||||
|
||||
-- Add invisivle character reperesentation
|
||||
vim.opt.list=true
|
||||
|
|
@ -54,6 +56,11 @@ vim.opt.inccommand = 'nosplit'
|
|||
-- Sets the default fold method to indent
|
||||
vim.opt.foldmethod = 'indent'
|
||||
|
||||
-- Shows cursor line
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- Completion Options
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||
|
||||
-- Need to find out how to do this in lua
|
||||
vim.cmd([[
|
||||
|
|
|
|||
2
nvim/.config/nvim/plugin/test.req
Normal file
2
nvim/.config/nvim/plugin/test.req
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
GET https://google.com
|
||||
User-Agent: MyNeovimClient
|
||||
|
|
@ -1,2 +1,5 @@
|
|||
Additionally
|
||||
vacuumed
|
||||
sufficient
|
||||
Redcentric
|
||||
Inadequate
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue