nvim and cheat

This commit is contained in:
2025-08-25 07:31:55 -04:00
parent 6e3a38a722
commit a71c14b9f6
7 changed files with 177 additions and 14 deletions

30
.config/cheat/glowpager.sh Executable file
View File

@@ -0,0 +1,30 @@
#! /bin/bash
# Create a temporary file
FILENAME=$(mktemp)
# Save the original file name in our temp file
cat > $FILENAME
# make sure variables exist and set default values otherwise
export LHOST="${LHOST:-$(command ip a | grep eth1 | grep inet | awk '{print($2)}' | cut -d '/' -f 1)}"
export LHOST="${LHOST:-$(command ip a | grep tun0 | grep inet | awk '{print($2)}' | cut -d '/' -f 1)}"
export LHOST="${LHOST:-\$LHOST}"
export LPORT="${LPORT:-\$LPORT}"
if [ $USER = "kali" ]; then
unset USER
fi
export USER="${USER:-\$USER}"
export PASS="${PASS:-\$PASS}"
export DOMAIN="${DOMAIN:-\$DOMAIN}"
export DCIP="${DCIP:-\$DCIP}"
export DC="${DC:-\$DC}"
# Get the file content and substitute environment variables
TEMPCONTENT=$(command cat $FILENAME | envsubst '$LPORT' | envsubst '$LHOST' | envsubst '$USER' | envsubst '$PASS' | envsubst '$DOMAIN' | envsubst '$DC' | envsubst '$DCIP' )
# Delete the tempfile again
rm $TEMPFILE
# Output the content as markdown with glow
echo "$TEMPCONTENT" | glow --style "$XDG_CONFIG_HOME/glow/dark.json" | sed 's/\\x1b/\x1b/g'

View File

@@ -8,18 +8,21 @@
"lazydev.nvim": { "branch": "main", "commit": "a1b78b2ac6f978c72e76ea90ae92a94edf380cfc" },
"lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "805c31ec6bfb557975143712ecff6956d3227141" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "09220b99d63d5363f219daa2785242ee5fddba7f" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.icons": { "branch": "main", "commit": "ec61af6e606fc89ee3b1d8f2f20166a3ca917a36" },
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-dap": { "branch": "master", "commit": "a720d4966f758ab22e8ec28812b6df90a53e0f02" },
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
"nvim-highlight-colors": { "branch": "main", "commit": "16a3cd4a32a655c8537de6e5643c234a9b38183a" },
"nvim-lspconfig": { "branch": "master", "commit": "6c17f8656f667727b27f5f598463afedb7791b18" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-scrollbar": { "branch": "main", "commit": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49" },
"nvim-treesitter": { "branch": "master", "commit": "6d957c22cb48a734b009a69d03c18d20042c4754" },
"nvim-web-devicons": { "branch": "master", "commit": "1020869742ecb191f260818234517f4a1515cfe8" },
"oil.nvim": { "branch": "master", "commit": "32dd3e378d47673679e76a773451f82f971a66df" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"rustaceanvim": { "branch": "master", "commit": "2b0f0b7e03751cf8ed123322f9b02d8f73fa9df7" },
"snacks.nvim": { "branch": "main", "commit": "121e74e4a5b7962ee370a8d8ae75d1c7b4c2e11c" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },

View File

@@ -0,0 +1,97 @@
return {
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',
-- Installs the debug adapters for you
'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
-- Add your own debuggers here
--
},
keys = {
-- Basic debugging keymaps, feel free to change to your liking!
{ '<F5>', function() require('dap').continue() end, desc = 'Debug: Start/Continue', },
{ '<F1>', function() require('dap').step_into() end, desc = 'Debug: Step Into', },
{ '<F2>', function() require('dap').step_over() end, desc = 'Debug: Step Over', },
{ '<F3>', function() require('dap').step_out() end, desc = 'Debug: Step Out', },
{ '<leader>b', function() require('dap').toggle_breakpoint() end, desc = 'Debug: Toggle Breakpoint', },
{ '<leader>B', function() require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, desc = 'Debug: Set Breakpoint', },
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
{ '<F7>', function() require('dapui').toggle() end, desc = 'Debug: See last session result.', },
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
},
}
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
}
-- Change breakpoint icons
vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
local breakpoint_icons = vim.g.have_nerd_font
and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
or { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
for type, icon in pairs(breakpoint_icons) do
local tp = 'Dap' .. type
local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
end
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Install golang specific config
-- require('dap-go').setup {
-- delve = {
-- -- On Windows delve must be run attached or it crashes.
-- -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
-- detached = vim.fn.has 'win32' == 0,
-- },
-- }
end,
}

View File

@@ -17,9 +17,11 @@ return {
},
handlers = {
function(server_name)
require("lspconfig")[server_name].setup({
capabilities = capabilities
})
if server_name ~= 'rust_analyzer' then
require("lspconfig")[server_name].setup({
capabilities = capabilities
})
end
end,
["ansiblels"] = function()
@@ -30,11 +32,19 @@ return {
})
end,
["rust-analyzer"] = function()
-- Do not initialize rust-analyzer so we can use rustaceanvim
require("lspconfig")['rust-analyzer'].setup({
cargo = {
buildScripts = {
enable = true,
features = {
"dns"
},
target = {
"x86_64-pc-windows-gnu"
}
-- buildScripts = {
-- enable = true,
-- },
},
filetypes = {
"rs",
@@ -74,11 +84,11 @@ return {
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("n", "<leader>cr", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
-- Format on save
if client.supports_method('textDocument/formatting') and vim.bo.filetype == "lua" then
if client.supports_method('textDocument/formatting') and vim.bo.filetype == "lua" or vim.bo.filetype == "rs" then
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = ev.buf,
callback = function()
@@ -101,9 +111,27 @@ return {
})
end
},
-- {
-- 'mrcjkb/rustaceanvim',
-- version = '^5', -- Recommended
-- lazy = false, -- This plugin is already lazy
-- }
{
'mrcjkb/rustaceanvim',
version = '^5', -- Recommended
lazy = false, -- This plugin is already lazy
dependencies = {
"williamboman/mason.nvim", -- https://github.com/williamboman/mason.nvim
"neovim/nvim-lspconfig", -- https://github.com/neovim/nvim-lspconfig
},
config = function()
local mason_registry = require('mason-registry')
local codelldb = mason_registry.get_package('codelldb')
local extension_path = codelldb:get_install_path() .. "/extension/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
local cfg = require('rustaceanvim.config')
vim.g.rustaceanvim = {
dap = {
adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path)
},
}
end,
}
}

View File

@@ -121,6 +121,7 @@ return {
},
lualine_c = { {
'filename',
path = 3,
on_click = function(nc, mb, mods)
local tb = require("telescope.builtin")
if mb == "l" then

View File

@@ -15,6 +15,8 @@ return {
statuscolumn = { enabled = true },
image = { enabled = true },
words = { enabled = true },
indent = { enabled = true },
lazygit = { enabled = true },
},
init = function()
vim.api.nvim_create_autocmd("User", {

View File

@@ -13,4 +13,6 @@ alias oclip='xclip -o -sel clipboard'
alias clip='xclip -sel clipboard'
alias x=xdg-open
alias sortip='sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4'
alias sortip='sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4'
alias open-ports="cat *.nmap | awk -F'/' '/open/{print \$1}' | sort -n -u"