From 5b44925a9a2600065370ebe9593cb2ac984fb80b Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Sat, 15 Nov 2025 11:00:36 +0000 Subject: [PATCH] nvim stuff --- bin/.bin/nessus-extract-ips | 3 + nvim/.config/nvim/after/plugin/rt-cmp.lua | 60 +++++ nvim/.config/nvim/after/plugin/tags.lua | 45 ++++ nvim/.config/nvim/autoload/mine/functions.vim | 14 ++ .../nvim/indent/{php.vim => php.vim.old} | 2 +- nvim/.config/nvim/init.lua | 64 ------ nvim/.config/nvim/lua/plugins/cmp.lua | 207 ++++++++++++++++-- .../plugins/{gruvbox.lua => colorscheme.lua} | 22 +- nvim/.config/nvim/lua/plugins/git.lua | 4 + nvim/.config/nvim/lua/plugins/image.lua | 34 +++ nvim/.config/nvim/lua/plugins/img-paste.lua | 17 ++ nvim/.config/nvim/lua/plugins/init.lua | 10 +- .../nvim/lua/plugins/jq-playground.lua | 3 + nvim/.config/nvim/lua/plugins/lualine.lua | 45 ++++ nvim/.config/nvim/lua/plugins/oil.lua | 27 +++ nvim/.config/nvim/lua/plugins/ollama.lua | 57 +++++ nvim/.config/nvim/lua/plugins/query editor | 14 ++ nvim/.config/nvim/lua/plugins/test.md | 17 ++ nvim/.config/nvim/plugin/decoder.lua.tmp | 130 +++++++++++ nvim/.config/nvim/plugin/deoplete.vim | 10 - nvim/.config/nvim/plugin/httprequest.lua | 79 +++++++ nvim/.config/nvim/plugin/mappings.lua | 4 +- nvim/.config/nvim/plugin/omnisharp.vim | 41 ---- nvim/.config/nvim/plugin/projectionist.vim | 25 --- nvim/.config/nvim/plugin/settings.lua | 7 + .../{statusline.vim => statusline.vim.old} | 0 nvim/.config/nvim/plugin/test.req | 2 + nvim/.config/nvim/spell/en.utf-8.add | 3 + nvim/.config/nvim/spell/en.utf-8.add.spl | Bin 67 -> 136 bytes 29 files changed, 775 insertions(+), 171 deletions(-) create mode 100755 bin/.bin/nessus-extract-ips create mode 100644 nvim/.config/nvim/after/plugin/rt-cmp.lua create mode 100644 nvim/.config/nvim/after/plugin/tags.lua rename nvim/.config/nvim/indent/{php.vim => php.vim.old} (99%) rename nvim/.config/nvim/lua/plugins/{gruvbox.lua => colorscheme.lua} (52%) create mode 100644 nvim/.config/nvim/lua/plugins/git.lua create mode 100644 nvim/.config/nvim/lua/plugins/image.lua create mode 100644 nvim/.config/nvim/lua/plugins/img-paste.lua create mode 100644 nvim/.config/nvim/lua/plugins/jq-playground.lua create mode 100644 nvim/.config/nvim/lua/plugins/lualine.lua create mode 100644 nvim/.config/nvim/lua/plugins/oil.lua create mode 100644 nvim/.config/nvim/lua/plugins/ollama.lua create mode 100644 nvim/.config/nvim/lua/plugins/query editor create mode 100644 nvim/.config/nvim/lua/plugins/test.md create mode 100644 nvim/.config/nvim/plugin/decoder.lua.tmp delete mode 100644 nvim/.config/nvim/plugin/deoplete.vim create mode 100644 nvim/.config/nvim/plugin/httprequest.lua delete mode 100644 nvim/.config/nvim/plugin/omnisharp.vim delete mode 100644 nvim/.config/nvim/plugin/projectionist.vim rename nvim/.config/nvim/plugin/{statusline.vim => statusline.vim.old} (100%) create mode 100644 nvim/.config/nvim/plugin/test.req diff --git a/bin/.bin/nessus-extract-ips b/bin/.bin/nessus-extract-ips new file mode 100755 index 00000000..ced183ec --- /dev/null +++ b/bin/.bin/nessus-extract-ips @@ -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' diff --git a/nvim/.config/nvim/after/plugin/rt-cmp.lua b/nvim/.config/nvim/after/plugin/rt-cmp.lua new file mode 100644 index 00000000..264b02ce --- /dev/null +++ b/nvim/.config/nvim/after/plugin/rt-cmp.lua @@ -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()) diff --git a/nvim/.config/nvim/after/plugin/tags.lua b/nvim/.config/nvim/after/plugin/tags.lua new file mode 100644 index 00000000..5d06a5a5 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/tags.lua @@ -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()) diff --git a/nvim/.config/nvim/autoload/mine/functions.vim b/nvim/.config/nvim/autoload/mine/functions.vim index aa6d85a7..a33b9069 100644 --- a/nvim/.config/nvim/autoload/mine/functions.vim +++ b/nvim/.config/nvim/autoload/mine/functions.vim @@ -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 ! !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 diff --git a/nvim/.config/nvim/indent/php.vim b/nvim/.config/nvim/indent/php.vim.old similarity index 99% rename from nvim/.config/nvim/indent/php.vim rename to nvim/.config/nvim/indent/php.vim.old index 3c498a71..c7d27d13 100644 --- a/nvim/.config/nvim/indent/php.vim +++ b/nvim/.config/nvim/indent/php.vim.old @@ -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") diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 2b3c7bd5..1375733f 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -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 <", function () --- return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" --- end, expr = true, silent = true, mode = "i" --- }, --- { "", function() require("luasnip").jump(1) end, mode = "s" }, --- { "", 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 = { + { "", function () + local ls = require("luasnip") + if ( ls.expand_or_jumpable() ) then + return ls.expand_or_jump() + end + end, mode = {"i","s"} + }, + { "", function () + local ls = require("luasnip") + ls.jump(-1) + end, mode = {"i","s"} + }, + { "", 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 {{ [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), + [''] = 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 }} - - diff --git a/nvim/.config/nvim/lua/plugins/gruvbox.lua b/nvim/.config/nvim/lua/plugins/colorscheme.lua similarity index 52% rename from nvim/.config/nvim/lua/plugins/gruvbox.lua rename to nvim/.config/nvim/lua/plugins/colorscheme.lua index 0dec88cd..e9e7ad83 100644 --- a/nvim/.config/nvim/lua/plugins/gruvbox.lua +++ b/nvim/.config/nvim/lua/plugins/colorscheme.lua @@ -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 diff --git a/nvim/.config/nvim/lua/plugins/git.lua b/nvim/.config/nvim/lua/plugins/git.lua new file mode 100644 index 00000000..0a566793 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/git.lua @@ -0,0 +1,4 @@ +return { + { "tpope/vim-fugitive" }, + { "lewis6991/gitsigns.nvim", opts={} } +} diff --git a/nvim/.config/nvim/lua/plugins/image.lua b/nvim/.config/nvim/lua/plugins/image.lua new file mode 100644 index 00000000..b2a98e2f --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/image.lua @@ -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", "ti", function() + if image.is_enabled() then + image.disable() + else + image.enable() + end + end, {}) + end, +}} diff --git a/nvim/.config/nvim/lua/plugins/img-paste.lua b/nvim/.config/nvim/lua/plugins/img-paste.lua new file mode 100644 index 00000000..06cb6511 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/img-paste.lua @@ -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 = "![](%s)" + } + } + + end +} diff --git a/nvim/.config/nvim/lua/plugins/init.lua b/nvim/.config/nvim/lua/plugins/init.lua index c7017034..e6efe2fd 100644 --- a/nvim/.config/nvim/lua/plugins/init.lua +++ b/nvim/.config/nvim/lua/plugins/init.lua @@ -1,3 +1,7 @@ -return { { - "tpope/vim-fugitive" -} } +return { + { "numToStr/Comment.nvim", opts={} } +} +-- Look into https://github.com/Exafunction/codeium.vim + + + diff --git a/nvim/.config/nvim/lua/plugins/jq-playground.lua b/nvim/.config/nvim/lua/plugins/jq-playground.lua new file mode 100644 index 00000000..5c656946 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/jq-playground.lua @@ -0,0 +1,3 @@ +return { + { 'yochem/jq-playground.nvim' } +} diff --git a/nvim/.config/nvim/lua/plugins/lualine.lua b/nvim/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 00000000..e647c4f8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lualine.lua @@ -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 = {} + } +} diff --git a/nvim/.config/nvim/lua/plugins/oil.lua b/nvim/.config/nvim/lua/plugins/oil.lua new file mode 100644 index 00000000..ac7332ec --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/oil.lua @@ -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 = { + [""] = 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 +} diff --git a/nvim/.config/nvim/lua/plugins/ollama.lua b/nvim/.config/nvim/lua/plugins/ollama.lua new file mode 100644 index 00000000..d7eaab2d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/ollama.lua @@ -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 is important for selections to work properly. + { + "oo", + ":lua require('ollama').prompt()", + desc = "ollama prompt", + mode = { "n", "v" }, + }, + + -- Sample keybind for direct prompting. Note that the is important for selections to work properly. + { + "oG", + ":lua require('ollama').prompt('Generate_Code')", + 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" + } + } + } +} diff --git a/nvim/.config/nvim/lua/plugins/query editor b/nvim/.config/nvim/lua/plugins/query editor new file mode 100644 index 00000000..2a6d3b37 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/query editor @@ -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) diff --git a/nvim/.config/nvim/lua/plugins/test.md b/nvim/.config/nvim/lua/plugins/test.md new file mode 100644 index 00000000..b534ec32 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/test.md @@ -0,0 +1,17 @@ + +:::indent + +#### Something (\High,\Low) + +some description + +##### Technical Details + +something + +##### Recommendation + +something + +::: +something diff --git a/nvim/.config/nvim/plugin/decoder.lua.tmp b/nvim/.config/nvim/plugin/decoder.lua.tmp new file mode 100644 index 00000000..66f9ca69 --- /dev/null +++ b/nvim/.config/nvim/plugin/decoder.lua.tmp @@ -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', '', ':lua save_and_replace("' .. selected_text .. '", "' .. choice .. '", ' .. popup_buf .. ')', { 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', 'diw', ':lua open_popup("iw")', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'di(', ':lua open_popup("i(")', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'di{', ':lua open_popup("i{")', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'di[', ':lua open_popup("i[")', { noremap = true, silent = true }) diff --git a/nvim/.config/nvim/plugin/deoplete.vim b/nvim/.config/nvim/plugin/deoplete.vim deleted file mode 100644 index 0a777bfd..00000000 --- a/nvim/.config/nvim/plugin/deoplete.vim +++ /dev/null @@ -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! diff --git a/nvim/.config/nvim/plugin/httprequest.lua b/nvim/.config/nvim/plugin/httprequest.lua new file mode 100644 index 00000000..234e0746 --- /dev/null +++ b/nvim/.config/nvim/plugin/httprequest.lua @@ -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, {}) diff --git a/nvim/.config/nvim/plugin/mappings.lua b/nvim/.config/nvim/plugin/mappings.lua index 4a856d2c..3e580851 100644 --- a/nvim/.config/nvim/plugin/mappings.lua +++ b/nvim/.config/nvim/plugin/mappings.lua @@ -33,7 +33,7 @@ end -- `] - go to the end of the last changed word -- a - enter insert mode -- u - break undo sequence (new change) -vim.keymap.set('i', '','u[s1z=`]au', {desc="Fix previous spelling mistake"}) +vim.keymap.set('i', '','u[s1z=`]au', {desc="Fix previous spelling mistake"}) -- Do Shebang line -- - go into normal mode @@ -42,7 +42,7 @@ vim.keymap.set('i', '','u[s1z=`]au', {desc="Fix previous spe -- - used to seperate commands -- filetype detect - attempt to detect filetype again -- :nohlsearch - un-hilight the search pattern -vim.keymap.set('i', '', ':silent s/^/#!\\/usr\\/bin\\/env / filetype detect:nohlsearcho', {desc="do shebang line"}) +--vim.keymap.set('i', '', ':silent s/^/#!\\/usr\\/bin\\/env / filetype detect:nohlsearcho', {desc="do shebang line"}) -- Makes delete key work properly in insert mode diff --git a/nvim/.config/nvim/plugin/omnisharp.vim b/nvim/.config/nvim/plugin/omnisharp.vim deleted file mode 100644 index 79399f0e..00000000 --- a/nvim/.config/nvim/plugin/omnisharp.vim +++ /dev/null @@ -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 (omnisharp_go_to_definition) - autocmd FileType cs nmap osfi (omnisharp_find_implementations) - autocmd FileType cs nmap ospd (omnisharp_preview_definition) - autocmd FileType cs nmap ospi (omnisharp_preview_implementations) - autocmd FileType cs nmap K (omnisharp_type_lookup) - autocmd FileType cs nmap osd (omnisharp_documentation) - autocmd FileType cs nmap osfs (omnisharp_find_symbol) - autocmd FileType cs nmap osfx (omnisharp_fix_usings) - - " Navigate up and down by method/property/field - autocmd FileType cs nmap [[ (omnisharp_navigate_up) - autocmd FileType cs nmap ]] (omnisharp_navigate_down) - " Find all code errors/warnings for the current solution and populate the quickfix window - autocmd FileType cs nmap osgcc (omnisharp_global_code_check) - " Contextual code actions (uses fzf, vim-clap, CtrlP or unite.vim selector when available) - autocmd FileType cs nmap osca (omnisharp_code_actions) - autocmd FileType cs xmap osca (omnisharp_code_actions) - " Repeat the last code action performed (does not use a selector) - autocmd FileType cs nmap os. (omnisharp_code_action_repeat) - autocmd FileType cs xmap os. (omnisharp_code_action_repeat) - - autocmd FileType cs nmap os= (omnisharp_code_format) - - autocmd FileType cs nmap osnm (omnisharp_rename) - - autocmd FileType cs nmap osre (omnisharp_restart_server) - autocmd FileType cs nmap osst (omnisharp_start_server) - autocmd FileType cs nmap ossp (omnisharp_stop_server) -augroup END diff --git a/nvim/.config/nvim/plugin/projectionist.vim b/nvim/.config/nvim/plugin/projectionist.vim deleted file mode 100644 index f1020325..00000000 --- a/nvim/.config/nvim/plugin/projectionist.vim +++ /dev/null @@ -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' - \ }, - \ } -\} diff --git a/nvim/.config/nvim/plugin/settings.lua b/nvim/.config/nvim/plugin/settings.lua index b8c3aef4..d2fccbd1 100644 --- a/nvim/.config/nvim/plugin/settings.lua +++ b/nvim/.config/nvim/plugin/settings.lua @@ -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([[ diff --git a/nvim/.config/nvim/plugin/statusline.vim b/nvim/.config/nvim/plugin/statusline.vim.old similarity index 100% rename from nvim/.config/nvim/plugin/statusline.vim rename to nvim/.config/nvim/plugin/statusline.vim.old diff --git a/nvim/.config/nvim/plugin/test.req b/nvim/.config/nvim/plugin/test.req new file mode 100644 index 00000000..54bc97cb --- /dev/null +++ b/nvim/.config/nvim/plugin/test.req @@ -0,0 +1,2 @@ +GET https://google.com +User-Agent: MyNeovimClient diff --git a/nvim/.config/nvim/spell/en.utf-8.add b/nvim/.config/nvim/spell/en.utf-8.add index 1e1d0da6..6be03f20 100644 --- a/nvim/.config/nvim/spell/en.utf-8.add +++ b/nvim/.config/nvim/spell/en.utf-8.add @@ -1,2 +1,5 @@ Additionally vacuumed +sufficient +Redcentric +Inadequate diff --git a/nvim/.config/nvim/spell/en.utf-8.add.spl b/nvim/.config/nvim/spell/en.utf-8.add.spl index 87d9f51d997d47d6fc17b90059df5f6c4f15e2bf..fd3ba098b401fd1655c2d4908e4a6cdea09116b3 100644 GIT binary patch literal 136 zcmXYqOA3H63`8>pZ{aDtg$sA$UYZJp`s+vV^g4brB#<`~GPGUVTnNo2B3g|;rUOcO yWcG>$BLa28n0HY)>?p(;5UCw^h2>mGB99(wnV2X~$N!%2=HUf12~)lD=~p)|>l!rx literal 67 zcmWIZ^erw(&B-zP&%nT-&6HTim;!{Ej3q#v&zQ%U$e06!m5fYGKxQ&yDG=r|rUI1! Hl|umlB