commit
004cf44189
@ -0,0 +1,175 @@
|
|||||||
|
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||||
|
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||||
|
# for examples
|
||||||
|
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
case $- in
|
||||||
|
*i*) ;;
|
||||||
|
*) return ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
export EDITOR=vim
|
||||||
|
# export LC_ALL=en_US.UTF-8
|
||||||
|
# export LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
##===== HISTORY =====##
|
||||||
|
|
||||||
|
# don't put duplicate lines or lines starting with space in the history.
|
||||||
|
# See bash(1) for more options
|
||||||
|
HISTCONTROL=ignoreboth
|
||||||
|
|
||||||
|
# append to the history file, don't overwrite it
|
||||||
|
shopt -s histappend
|
||||||
|
|
||||||
|
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) and add timestamp (HISTTIMEFORMAT)
|
||||||
|
HISTSIZE=10000
|
||||||
|
HISTFILESIZE=20000
|
||||||
|
HISTTIMEFORMAT="%d/%m/%y %T "
|
||||||
|
|
||||||
|
##===== Looks =====##
|
||||||
|
|
||||||
|
# check the window size after each command and, if necessary,
|
||||||
|
# update the values of LINES and COLUMNS.
|
||||||
|
shopt -s checkwinsize
|
||||||
|
|
||||||
|
# If set, the pattern "**" used in a pathname expansion context will
|
||||||
|
# match all files and zero or more directories and subdirectories.
|
||||||
|
#shopt -s globstar
|
||||||
|
|
||||||
|
# make less more friendly for non-text input files, see lesspipe(1)
|
||||||
|
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||||
|
|
||||||
|
# set variable identifying the chroot you work in (used in the prompt below)
|
||||||
|
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||||
|
debian_chroot=$(cat /etc/debian_chroot)
|
||||||
|
fi
|
||||||
|
|
||||||
|
color_prompt=yes
|
||||||
|
|
||||||
|
# Change this to the apropriate environment (dev|test|prod)
|
||||||
|
ENVIRONMENT=TEST
|
||||||
|
|
||||||
|
# I normaly have a green prompt on my local, yellow on Test and QA and red on Production systems
|
||||||
|
#if [ "$color_prompt" = yes ]; then
|
||||||
|
case "${ENVIRONMENT}" in
|
||||||
|
"DEV")
|
||||||
|
# Green prompt
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
|
;;
|
||||||
|
"TEST")
|
||||||
|
# Yellow prompt
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
|
;;
|
||||||
|
"PROD")
|
||||||
|
# Red prompt
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[00;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# colored GCC warnings and errors
|
||||||
|
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||||
|
|
||||||
|
# Add color to MAN pages,
|
||||||
|
## from https://www.tecmint.com/view-colored-man-pages-in-linux/
|
||||||
|
## by Aaron Kili, Published: December 12, 2017
|
||||||
|
export LESS_TERMCAP_mb=$'\e[1;32m'
|
||||||
|
export LESS_TERMCAP_md=$'\e[1;32m'
|
||||||
|
export LESS_TERMCAP_me=$'\e[0m'
|
||||||
|
export LESS_TERMCAP_se=$'\e[0m'
|
||||||
|
export LESS_TERMCAP_so=$'\e[01;33m'
|
||||||
|
export LESS_TERMCAP_ue=$'\e[0m'
|
||||||
|
export LESS_TERMCAP_us=$'\e[1;4;31m'
|
||||||
|
|
||||||
|
##===== Completion =====##
|
||||||
|
|
||||||
|
# enable programmable completion features (you don't need to enable
|
||||||
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||||
|
# sources /etc/bash.bashrc).
|
||||||
|
if ! shopt -oq posix; then
|
||||||
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||||
|
. /usr/share/bash-completion/bash_completion
|
||||||
|
elif [ -f /etc/bash_completion ]; then
|
||||||
|
. /etc/bash_completion
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f ${HOME}/.lib/q_completion.sh ]; then
|
||||||
|
source ${HOME}/.lib/q_completion.sh
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
###===== HOMEBREW =====##
|
||||||
|
test -d /opt/homebrew && export PATH=/opt/homebrew/bin:~/bin:$PATH
|
||||||
|
|
||||||
|
###===== MQ and IIB =====##
|
||||||
|
#
|
||||||
|
## Add mq bin folder to PATH
|
||||||
|
test -d /opt/mqm/bin && export PATH=$PATH:/opt/mqm/bin
|
||||||
|
#
|
||||||
|
## Load MQSI profile
|
||||||
|
if [ -f /opt/IBM/iib-10.0.0.10/server/bin/mqsiprofile ]; then
|
||||||
|
[ -z "${PROSPECTIVE_MQSI_BASE_FILEPATH+MQSI_PROFILE_NOT_SET}" ] && source /opt/IBM/iib-10.0.0.10/server/bin/mqsiprofile
|
||||||
|
fi
|
||||||
|
|
||||||
|
##===== Alias definitions =====##
|
||||||
|
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
alias dir='dir --color=auto'
|
||||||
|
alias vdir='vdir --color=auto'
|
||||||
|
|
||||||
|
alias grep='grep --color=auto'
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# some more ls aliases
|
||||||
|
alias ll='ls -alF'
|
||||||
|
alias la='ls -A'
|
||||||
|
alias l='ls -CF'
|
||||||
|
|
||||||
|
alias ws='cd ~/Documents/Code'
|
||||||
|
alias vcc='cd ~/Documents/Code/VOLVOCARS/'
|
||||||
|
|
||||||
|
alias doc='cd ~/Documents'
|
||||||
|
alias dw='cd ~/Downloads'
|
||||||
|
|
||||||
|
alias wn='cd ~/.config/nvim/'
|
||||||
|
alias cv='cd ~/.config/nvim/ ; vim init.norg lua/plugins.lua'
|
||||||
|
|
||||||
|
alias :q='exit'
|
||||||
|
alias vim='nvim'
|
||||||
|
alias nn='cd ~/notes/; nvim $(ls -tr $(ls -tr |grep -v "inbox.norg" | grep -e "[.]norg$" |tail -n1) $(ls -tr | grep -e "[.]md$" |tail -n1)); updateNotes.sh; cd -'
|
||||||
|
#
|
||||||
|
##===== Custom functions =====##
|
||||||
|
|
||||||
|
sleepUntil() { # args [-q] <HH[:MM[:SS]]> [more days]
|
||||||
|
if [ "$1" = "" ]; then
|
||||||
|
echo "args [-q] <HH[:MM[:SS]]> [more days]"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local slp tzoff now quiet=false
|
||||||
|
[ "$1" = "-q" ] && shift && quiet=true
|
||||||
|
local -a hms=(${1//:/ })
|
||||||
|
printf -v now '%(%s)T' -1
|
||||||
|
printf -v tzoff '%(%z)T\n' $now
|
||||||
|
tzoff=$((0${tzoff:0:1}(3600*${tzoff:1:2}+60*${tzoff:3:2})))
|
||||||
|
slp=$((
|
||||||
|
( 86400+(now-now%86400) + 10#$hms*3600 + 10#${hms[1]}*60 +
|
||||||
|
${hms[2]}-tzoff-now ) %86400 + ${2:-0}*86400
|
||||||
|
))
|
||||||
|
$quiet || printf 'sleep %ss, -> %(%c)T\n' $slp $((now+slp))
|
||||||
|
sleep $slp
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add JBang to environment
|
||||||
|
#alias j!=jbang
|
||||||
|
export JAVA_HOME=$(/usr/libexec/java_home -v 19.0.2 -V 2>&1 |grep -oe "\S\+zulu\S\+$")
|
||||||
|
test -d /opt/homebrew/opt/openjdk/bin && export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
|
||||||
|
test -d /opt/homebrew/opt/curl/bin && export PATH="/opt/homebrew/opt/curl/bin:$PATH"
|
||||||
|
export PATH="/Users/nige/.cargo/bin:$PATH"
|
||||||
|
|
||||||
|
export GOPATH=$HOME/go
|
||||||
|
which brew && export GOROOT="$(brew --prefix golang)/libexec"
|
||||||
|
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
|
@ -0,0 +1,11 @@
|
|||||||
|
# Custom configuration
|
||||||
|
# This file needs to be referenced from the global .gitconfig file and copied as
|
||||||
|
# .gitconfig into the root folder containing all repositories that it should be
|
||||||
|
# used on.
|
||||||
|
# EXAMPLE reference in global .gitconfig:
|
||||||
|
# [includeIf "gitdir:~/siv-dev/client-work/"]
|
||||||
|
# path = ~/siv-dev/client-work/.gitconfig
|
||||||
|
|
||||||
|
[user]
|
||||||
|
name = Nils Gerstner
|
||||||
|
email = nils@gerstner.se
|
@ -0,0 +1,11 @@
|
|||||||
|
# Custom configuration
|
||||||
|
# This file needs to be referenced from the global .gitconfig file and copied as
|
||||||
|
# .gitconfig into the root folder containing all repositories that it should be
|
||||||
|
# used on.
|
||||||
|
# EXAMPLE reference in global .gitconfig:
|
||||||
|
# [includeIf "gitdir:~/siv-dev/client-work/"]
|
||||||
|
# path = ~/siv-dev/client-work/.gitconfig
|
||||||
|
|
||||||
|
[user]
|
||||||
|
name = Nils Gerstner
|
||||||
|
email = nils.gerstner@replyto.se
|
@ -0,0 +1,11 @@
|
|||||||
|
# Custom configuration
|
||||||
|
# This file needs to be referenced from the global .gitconfig file and copied as
|
||||||
|
# .gitconfig into the root folder containing all repositories that it should be
|
||||||
|
# used on.
|
||||||
|
# EXAMPLE reference in global .gitconfig:
|
||||||
|
# [includeIf "gitdir:~/siv-dev/client-work/"]
|
||||||
|
# path = ~/siv-dev/client-work/.gitconfig
|
||||||
|
|
||||||
|
[user]
|
||||||
|
name = Nils Gerstner
|
||||||
|
email = nils.gerstner@volvocars.com
|
@ -0,0 +1 @@
|
|||||||
|
{"contents":[{"text":"nvim"}],"icon":" ","uid":"20230115195355","type":1}
|
@ -0,0 +1,118 @@
|
|||||||
|
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
|
||||||
|
local config = {
|
||||||
|
-- The command that starts the language server
|
||||||
|
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
|
||||||
|
autostart = true,
|
||||||
|
-- autostart = false,
|
||||||
|
cmd = {
|
||||||
|
|
||||||
|
--[[
|
||||||
|
usage: jdtls [-h] [--validate-java-version | --no-validate-java-version] [--jvm-arg JVM_ARG] [-data DATA]
|
||||||
|
|
||||||
|
options:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
--validate-java-version, --no-validate-java-version
|
||||||
|
--jvm-arg JVM_ARG An additional JVM option (can be used multiple times. Note, use with equal sign. For example: --jvm-arg=-Dlog.level=ALL
|
||||||
|
-data DATA
|
||||||
|
]]
|
||||||
|
|
||||||
|
'jdtls',
|
||||||
|
'-configuration',
|
||||||
|
'/Users/nige/.cache/jdtls/config',
|
||||||
|
-- '-data', '/Users/nige/.cache/jdtls/workspace'
|
||||||
|
-- 'jdtls',
|
||||||
|
-- '--jvm-arg=-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||||
|
-- '--jvm-arg=-Dosgi.bundles.defaultStartLevel=4',
|
||||||
|
-- '--jvm-arg=-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||||
|
-- '--jvm-arg=-Dlog.protocol=true',
|
||||||
|
-- '--jvm-arg=-Dlog.level=ALL',
|
||||||
|
-- '--jvm-arg=-Xms1g',
|
||||||
|
-- '--jvm-arg=--add-modules=ALL-SYSTEM',
|
||||||
|
-- '--jvm-arg=--add-opens java.base/java.util=ALL-UNNAMED',
|
||||||
|
-- '--jvm-arg=--add-opens java.base/java.lang=ALL-UNNAMED', -- 💀
|
||||||
|
'-data', '/Users/nige/.config/jdtls_workspaces/' ..
|
||||||
|
vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- -- 💀
|
||||||
|
-- 'java', -- or '/path/to/java17_or_newer/bin/java'
|
||||||
|
-- -- depends on if `java` is in your $PATH env variable and if it points to the right version.
|
||||||
|
-- '-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||||
|
-- '-Dosgi.bundles.defaultStartLevel=4',
|
||||||
|
-- '-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||||
|
-- '-Dlog.protocol=true', '-Dlog.level=ALL', '-Xms1g',
|
||||||
|
-- '--add-modules=ALL-SYSTEM', '--add-opens',
|
||||||
|
-- 'java.base/java.util=ALL-UNNAMED', '--add-opens',
|
||||||
|
-- 'java.base/java.lang=ALL-UNNAMED', -- 💀
|
||||||
|
-- '-jar',
|
||||||
|
-- '/Users/nige/.local/share/lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar',
|
||||||
|
-- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
||||||
|
-- -- Must point to the Change this to
|
||||||
|
-- -- eclipse.jdt.ls installation the actual version
|
||||||
|
--
|
||||||
|
-- -- 💀
|
||||||
|
-- '-configuration', '/Users/nige/.local/share/lsp/jdtls/config_mac',
|
||||||
|
-- -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||||
|
-- -- Must point to the Change to one of `linux`, `win` or `mac`
|
||||||
|
-- -- eclipse.jdt.ls installation Depending on your system.
|
||||||
|
--
|
||||||
|
-- -- 💀
|
||||||
|
-- '-data', '/Users/nige/.config/jdtls_workspaces/' ..
|
||||||
|
-- vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||||
|
},
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
-- This is the default if not provided, you can remove it. Or adjust as needed.
|
||||||
|
-- One dedicated LSP server & client will be started per unique root_dir
|
||||||
|
root_dir = require('jdtls.setup').find_root({ '.git', 'mvnw', 'gradlew' }),
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
-- This is the default if not provided, you can remove it. Or adjust as needed.
|
||||||
|
-- One dedicated LSP server & client will be started per unique root_dir
|
||||||
|
|
||||||
|
-- Here you can configure eclipse.jdt.ls specific settings
|
||||||
|
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||||
|
-- for a list of options
|
||||||
|
settings = {
|
||||||
|
java = {
|
||||||
|
eclipse = { downloadSources = true },
|
||||||
|
implementationsCodeLens = { enabled = true },
|
||||||
|
import = { enabled = true },
|
||||||
|
maven = { downloadSources = true },
|
||||||
|
references = { includeDecompiledSources = true },
|
||||||
|
referencesCodeLens = { enabled = true },
|
||||||
|
rename = { enabled = true },
|
||||||
|
signatureHelp = { enabled = true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Language server `initializationOptions`
|
||||||
|
-- You need to extend the `bundles` with paths to jar files
|
||||||
|
-- if you want to use additional eclipse.jdt.ls plugins.
|
||||||
|
--
|
||||||
|
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
|
||||||
|
--
|
||||||
|
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
|
||||||
|
init_options = {
|
||||||
|
extendedClientCapabilities = { classFileContentsSupport = true },
|
||||||
|
-- bundles = {
|
||||||
|
-- vim.fn.glob(
|
||||||
|
-- "/Users/nige/.local/share/nvim/dap-servers/com.microsoft.java.debug.plugin_0.43.0.jar",
|
||||||
|
-- 1)
|
||||||
|
-- }
|
||||||
|
},
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
-- With `hotcodereplace = 'auto' the debug adapter will try to apply code changes
|
||||||
|
-- you make during a debug session immediately.
|
||||||
|
-- Remove the option if you do not want that.
|
||||||
|
-- You can use the `JdtHotcodeReplace` command to trigger it manually
|
||||||
|
-- require('jdtls').setup_dap({ hotcodereplace = 'auto' })
|
||||||
|
local jdtls = require('jdtls')
|
||||||
|
jdtls.setup_dap({ hotcodereplace = 'auto' })
|
||||||
|
jdtls.setup.add_commands()
|
||||||
|
end
|
||||||
|
}
|
||||||
|
-- This starts a new client & server,
|
||||||
|
-- or attaches to an existing client & server depending on the `root_dir`.
|
||||||
|
require('jdtls').start_or_attach(config)
|
@ -0,0 +1,2 @@
|
|||||||
|
require("setup")
|
||||||
|
require("note-workflow")
|
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"ChatGPT.nvim": { "branch": "main", "commit": "8797871b5d11d256834b1c474ca9016dd0137dcb" },
|
||||||
|
"Comment.nvim": { "branch": "master", "commit": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" },
|
||||||
|
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
|
||||||
|
"LuaSnip": { "branch": "master", "commit": "025886915e7a1442019f467e0ae2847a7cf6bf1a" },
|
||||||
|
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||||
|
"cmp-cmdline": { "branch": "main", "commit": "8fcc934a52af96120fe26358985c10c035984b53" },
|
||||||
|
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
|
||||||
|
"cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" },
|
||||||
|
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||||
|
"cmp-tabnine": { "branch": "main", "commit": "4c8a0db92e75c848fb066edd280072389db80d24" },
|
||||||
|
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||||
|
"follow-md-links.nvim": { "branch": "main", "commit": "ccc50e7ba191e62b4243ddd3db9b7dbddf2ee179" },
|
||||||
|
"friendly-snippets": { "branch": "main", "commit": "25ddcd96540a2ce41d714bd7fea2e7f75fea8ead" },
|
||||||
|
"harpoon": { "branch": "master", "commit": "f7040fd0c44e7a4010369136547de5604b9c22a1" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "a80422f21750fcbf0e90b26da877d4024d76f116" },
|
||||||
|
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
|
||||||
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "2b811031febe5f743e07305738181ff367e1e452" },
|
||||||
|
"mason-null-ls.nvim": { "branch": "main", "commit": "4070ec7c543b67df16143ee206e436d24bb9c01b" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1" },
|
||||||
|
"neogit": { "branch": "master", "commit": "039ff3212ec43cc4d3332956dfb54e263c8d5033" },
|
||||||
|
"neorg": { "branch": "main", "commit": "532548b9f444bd1ae6f2efd3edd842282cc79659" },
|
||||||
|
"neorg-telescope": { "branch": "main", "commit": "197c59a572e4423642b5c5fb727ecefadffe9000" },
|
||||||
|
"neotest": { "branch": "master", "commit": "bbbfa55d850f1aaa6707ea85fb5230ac866459c6" },
|
||||||
|
"neotest-vim-test": { "branch": "master", "commit": "07f25ab7ba4e7646b38c84e10002b195a53b0096" },
|
||||||
|
"nui.nvim": { "branch": "main", "commit": "0dc148c6ec06577fcf06cbab3b7dac96d48ba6be" },
|
||||||
|
"null-ls.nvim": { "branch": "main", "commit": "0180603b6f3cee40f83c6fc226b9ac5f85e691c4" },
|
||||||
|
"nvim-cmp": { "branch": "main", "commit": "777450fd0ae289463a14481673e26246b5e38bf2" },
|
||||||
|
"nvim-code-action-menu": { "branch": "main", "commit": "e4399dbaf6eabff998d3d5f1cbcd8d9933710027" },
|
||||||
|
"nvim-dap": { "branch": "master", "commit": "7e81998e31277c7a33b6c34423640900c5c2c776" },
|
||||||
|
"nvim-dap-ui": { "branch": "master", "commit": "bdb94e3853d11b5ce98ec182e5a3719d5c0ef6fd" },
|
||||||
|
"nvim-jdtls": { "branch": "master", "commit": "f8fb45e05e638e5c67e884f3039abcda7abc2d2d" },
|
||||||
|
"nvim-lightbulb": { "branch": "master", "commit": "56b9ce31ec9d09d560fe8787c0920f76bc208297" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "c6105c449683b944b5d2138fcf82f18c657249e9" },
|
||||||
|
"nvim-treesitter": { "branch": "master", "commit": "1f087c91f5ca76a2257b855d72d371a2b5302986" },
|
||||||
|
"nvim-ts-context-commentstring": { "branch": "main", "commit": "729d83ecb990dc2b30272833c213cc6d49ed5214" },
|
||||||
|
"peek.nvim": { "branch": "master", "commit": "571f14c795e8edd5a21e435f42f37c9bec4a8e16" },
|
||||||
|
"playground": { "branch": "master", "commit": "4044b53c4d4fcd7a78eae20b8627f78ce7dc6f56" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
|
||||||
|
"rose-pine": { "branch": "main", "commit": "17723f76ea78cdd71fd0007b7b760683b60a5e43" },
|
||||||
|
"tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" },
|
||||||
|
"telescope.nvim": { "branch": "master", "commit": "b79cd6c88b3d96b0f49cb7d240807cd59b610cd8" },
|
||||||
|
"tree-sitter-norg": { "branch": "main", "commit": "1a305093569632de50f9a316ff843dcda25b4ef5" },
|
||||||
|
"undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" },
|
||||||
|
"vim-markdown": { "branch": "master", "commit": "5d3d1b6cbdc4be0b4c6105c1ab1f769d76d3c68f" },
|
||||||
|
"vim-tickscript": { "branch": "master", "commit": "399e332b709f034421c83af9ea14380d71e0d743" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "87b1459b3e0be0340da2183fc4ec8a00b2960678" }
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"diagnostics.disable": [
|
||||||
|
"undefined-global",
|
||||||
|
"unused-local",
|
||||||
|
"unused-function"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,194 @@
|
|||||||
|
--[[ json.lua
|
||||||
|
|
||||||
|
A compact pure-Lua JSON library.
|
||||||
|
The main functions are: json.stringify, json.parse.
|
||||||
|
|
||||||
|
## json.stringify:
|
||||||
|
|
||||||
|
This expects the following to be true of any tables being encoded:
|
||||||
|
* They only have string or number keys. Number keys must be represented as
|
||||||
|
strings in json; this is part of the json spec.
|
||||||
|
* They are not recursive. Such a structure cannot be specified in json.
|
||||||
|
|
||||||
|
A Lua table is considered to be an array if and only if its set of keys is a
|
||||||
|
consecutive sequence of positive integers starting at 1. Arrays are encoded like
|
||||||
|
so: `[2, 3, false, "hi"]`. Any other type of Lua table is encoded as a json
|
||||||
|
object, encoded like so: `{"key1": 2, "key2": false}`.
|
||||||
|
|
||||||
|
Because the Lua nil value cannot be a key, and as a table value is considerd
|
||||||
|
equivalent to a missing key, there is no way to express the json "null" value in
|
||||||
|
a Lua table. The only way this will output "null" is if your entire input obj is
|
||||||
|
nil itself.
|
||||||
|
|
||||||
|
An empty Lua table, {}, could be considered either a json object or array -
|
||||||
|
it's an ambiguous edge case. We choose to treat this as an object as it is the
|
||||||
|
more general type.
|
||||||
|
|
||||||
|
To be clear, none of the above considerations is a limitation of this code.
|
||||||
|
Rather, it is what we get when we completely observe the json specification for
|
||||||
|
as arbitrary a Lua object as json is capable of expressing.
|
||||||
|
|
||||||
|
## json.parse:
|
||||||
|
|
||||||
|
This function parses json, with the exception that it does not pay attention to
|
||||||
|
\u-escaped unicode code points in strings.
|
||||||
|
|
||||||
|
It is difficult for Lua to return null as a value. In order to prevent the loss
|
||||||
|
of keys with a null value in a json string, this function uses the one-off
|
||||||
|
table value json.null (which is just an empty table) to indicate null values.
|
||||||
|
This way you can check if a value is null with the conditional
|
||||||
|
`val == json.null`.
|
||||||
|
|
||||||
|
If you have control over the data and are using Lua, I would recommend just
|
||||||
|
avoiding null values in your data to begin with.
|
||||||
|
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
local json = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- Internal functions.
|
||||||
|
|
||||||
|
local function kind_of(obj)
|
||||||
|
if type(obj) ~= 'table' then return type(obj) end
|
||||||
|
local i = 1
|
||||||
|
for _ in pairs(obj) do
|
||||||
|
if obj[i] ~= nil then i = i + 1 else return 'table' end
|
||||||
|
end
|
||||||
|
if i == 1 then return 'table' else return 'array' end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function escape_str(s)
|
||||||
|
local in_char = {'\\', '"', '/', '\b', '\f', '\n', '\r', '\t'}
|
||||||
|
local out_char = {'\\', '"', '/', 'b', 'f', 'n', 'r', 't'}
|
||||||
|
for i, c in ipairs(in_char) do
|
||||||
|
s = s:gsub(c, '\\' .. out_char[i])
|
||||||
|
end
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns pos, did_find; there are two cases:
|
||||||
|
-- 1. Delimiter found: pos = pos after leading space + delim; did_find = true.
|
||||||
|
-- 2. Delimiter not found: pos = pos after leading space; did_find = false.
|
||||||
|
-- This throws an error if err_if_missing is true and the delim is not found.
|
||||||
|
local function skip_delim(str, pos, delim, err_if_missing)
|
||||||
|
pos = pos + #str:match('^%s*', pos)
|
||||||
|
if str:sub(pos, pos) ~= delim then
|
||||||
|
if err_if_missing then
|
||||||
|
error('Expected ' .. delim .. ' near position ' .. pos)
|
||||||
|
end
|
||||||
|
return pos, false
|
||||||
|
end
|
||||||
|
return pos + 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Expects the given pos to be the first character after the opening quote.
|
||||||
|
-- Returns val, pos; the returned pos is after the closing quote character.
|
||||||
|
local function parse_str_val(str, pos, val)
|
||||||
|
val = val or ''
|
||||||
|
local early_end_error = 'End of input found while parsing string.'
|
||||||
|
if pos > #str then error(early_end_error) end
|
||||||
|
local c = str:sub(pos, pos)
|
||||||
|
if c == '"' then return val, pos + 1 end
|
||||||
|
if c ~= '\\' then return parse_str_val(str, pos + 1, val .. c) end
|
||||||
|
-- We must have a \ character.
|
||||||
|
local esc_map = {b = '\b', f = '\f', n = '\n', r = '\r', t = '\t'}
|
||||||
|
local nextc = str:sub(pos + 1, pos + 1)
|
||||||
|
if not nextc then error(early_end_error) end
|
||||||
|
return parse_str_val(str, pos + 2, val .. (esc_map[nextc] or nextc))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns val, pos; the returned pos is after the number's final character.
|
||||||
|
local function parse_num_val(str, pos)
|
||||||
|
local num_str = str:match('^-?%d+%.?%d*[eE]?[+-]?%d*', pos)
|
||||||
|
local val = tonumber(num_str)
|
||||||
|
if not val then error('Error parsing number at position ' .. pos .. '.') end
|
||||||
|
return val, pos + #num_str
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Public values and functions.
|
||||||
|
|
||||||
|
function json.stringify(obj, as_key)
|
||||||
|
local s = {} -- We'll build the string as an array of strings to be concatenated.
|
||||||
|
local kind = kind_of(obj) -- This is 'array' if it's an array or type(obj) otherwise.
|
||||||
|
if kind == 'array' then
|
||||||
|
if as_key then error('Can\'t encode array as key.') end
|
||||||
|
s[#s + 1] = '['
|
||||||
|
for i, val in ipairs(obj) do
|
||||||
|
if i > 1 then s[#s + 1] = ', ' end
|
||||||
|
s[#s + 1] = json.stringify(val)
|
||||||
|
end
|
||||||
|
s[#s + 1] = ']'
|
||||||
|
elseif kind == 'table' then
|
||||||
|
if as_key then error('Can\'t encode table as key.') end
|
||||||
|
s[#s + 1] = '{'
|
||||||
|
for k, v in pairs(obj) do
|
||||||
|
if #s > 1 then s[#s + 1] = ', ' end
|
||||||
|
s[#s + 1] = json.stringify(k, true)
|
||||||
|
s[#s + 1] = ':'
|
||||||
|
s[#s + 1] = json.stringify(v)
|
||||||
|
end
|
||||||
|
s[#s + 1] = '}'
|
||||||
|
elseif kind == 'string' then
|
||||||
|
return '"' .. escape_str(obj) .. '"'
|
||||||
|
elseif kind == 'number' then
|
||||||
|
if as_key then return '"' .. tostring(obj) .. '"' end
|
||||||
|
return tostring(obj)
|
||||||
|
elseif kind == 'boolean' then
|
||||||
|
return tostring(obj)
|
||||||
|
elseif kind == 'nil' then
|
||||||
|
return 'null'
|
||||||
|
else
|
||||||
|
error('Unjsonifiable type: ' .. kind .. '.')
|
||||||
|
end
|
||||||
|
return table.concat(s)
|
||||||
|
end
|
||||||
|
|
||||||
|
json.null = {} -- This is a one-off table to represent the null value.
|
||||||
|
|
||||||
|
function json.parse(str, pos, end_delim)
|
||||||
|
pos = pos or 1
|
||||||
|
if pos > #str then error('Reached unexpected end of input.') end
|
||||||
|
local pos = pos + #str:match('^%s*', pos) -- Skip whitespace.
|
||||||
|
local first = str:sub(pos, pos)
|
||||||
|
if first == '{' then -- Parse an object.
|
||||||
|
local obj, key, delim_found = {}, true, true
|
||||||
|
pos = pos + 1
|
||||||
|
while true do
|
||||||
|
key, pos = json.parse(str, pos, '}')
|
||||||
|
if key == nil then return obj, pos end
|
||||||
|
if not delim_found then error('Comma missing between object items.') end
|
||||||
|
pos = skip_delim(str, pos, ':', true) -- true -> error if missing.
|
||||||
|
obj[key], pos = json.parse(str, pos)
|
||||||
|
pos, delim_found = skip_delim(str, pos, ',')
|
||||||
|
end
|
||||||
|
elseif first == '[' then -- Parse an array.
|
||||||
|
local arr, val, delim_found = {}, true, true
|
||||||
|
pos = pos + 1
|
||||||
|
while true do
|
||||||
|
val, pos = json.parse(str, pos, ']')
|
||||||
|
if val == nil then return arr, pos end
|
||||||
|
if not delim_found then error('Comma missing between array items.') end
|
||||||
|
arr[#arr + 1] = val
|
||||||
|
pos, delim_found = skip_delim(str, pos, ',')
|
||||||
|
end
|
||||||
|
elseif first == '"' then -- Parse a string.
|
||||||
|
return parse_str_val(str, pos + 1)
|
||||||
|
elseif first == '-' or first:match('%d') then -- Parse a number.
|
||||||
|
return parse_num_val(str, pos)
|
||||||
|
elseif first == end_delim then -- End of an object or array.
|
||||||
|
return nil, pos + 1
|
||||||
|
else -- Parse true, false, or null.
|
||||||
|
local literals = {['true'] = true, ['false'] = false, ['null'] = json.null}
|
||||||
|
for lit_str, lit_val in pairs(literals) do
|
||||||
|
local lit_end = pos + #lit_str - 1
|
||||||
|
if str:sub(pos, lit_end) == lit_str then return lit_val, lit_end + 1 end
|
||||||
|
end
|
||||||
|
local pos_info_str = 'position ' .. pos .. ': ' .. str:sub(pos, pos + 10)
|
||||||
|
error('Invalid json syntax starting at ' .. pos_info_str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return json
|
@ -0,0 +1,9 @@
|
|||||||
|
local notesAutoCmd = vim.api.nvim_create_augroup("Notes-Workflow", { clear = true })
|
||||||
|
local delete = require('note-workflow.delete')
|
||||||
|
vim.api.nvim_create_autocmd(
|
||||||
|
{ "VimEnter" }, {
|
||||||
|
group = notesAutoCmd,
|
||||||
|
callback = delete.prune_search_db,
|
||||||
|
desc = "Prune Meilisearch from deleted documents",
|
||||||
|
}
|
||||||
|
)
|
@ -0,0 +1,39 @@
|
|||||||
|
M = {}
|
||||||
|
|
||||||
|
local config = require('note-workflow.notes').config_values
|
||||||
|
local prefix = config.prefix
|
||||||
|
local server = config.server
|
||||||
|
|
||||||
|
local function file_exists(name)
|
||||||
|
local f = io.open(name, "r")
|
||||||
|
if f ~= nil then
|
||||||
|
io.close(f)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.prune_search_db()
|
||||||
|
local curl = require "plenary.curl"
|
||||||
|
local json = require('json')
|
||||||
|
local hits = {}
|
||||||
|
|
||||||
|
local res = curl.get(server .. '/indexes/notes/documents?limit=99999999&fields=title,id', {
|
||||||
|
accept = "application/json",
|
||||||
|
})
|
||||||
|
|
||||||
|
if res then
|
||||||
|
local tab = json.parse(res.body)
|
||||||
|
if tab and tab['total'] > 0 then
|
||||||
|
for i, v in ipairs(tab['results']) do
|
||||||
|
if not file_exists(prefix .. v['title']) then
|
||||||
|
print('Delete ' .. v['title'] .. ' from search index')
|
||||||
|
curl.delete('http://localhost:7700/indexes/notes/documents/' .. v['id'], {})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -0,0 +1,2 @@
|
|||||||
|
require("note-workflow.autocmd")
|
||||||
|
require("note-workflow.keymap")
|
@ -0,0 +1,7 @@
|
|||||||
|
local note_workflow = require('note-workflow.notes')
|
||||||
|
vim.keymap.set("n", "<leader>ms", note_workflow.search, { desc = "Search Notes via Meilisearch" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>ma", note_workflow.updateAll, { desc = "Update notes" })
|
||||||
|
vim.keymap.set("n", "<leader>nz", note_workflow.newNeorgNote, { desc = "Create a new Neorg note" })
|
||||||
|
vim.keymap.set("n", "<leader>nm", note_workflow.newMarkdownNote, { desc = "Create a new Markdown note" })
|
||||||
|
vim.keymap.set("n", "<leader>nw", note_workflow.createWorknote, { desc = "Create an inline worknote" })
|
@ -0,0 +1,342 @@
|
|||||||
|
local q = require "vim.treesitter.query"
|
||||||
|
local ts_utils = require("nvim-treesitter.ts_utils")
|
||||||
|
local tprint = require("setup.utils").tprint
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.config_values = {
|
||||||
|
server = 'http://localhost:7700',
|
||||||
|
dateformat = '%Y%m%d%H%M-',
|
||||||
|
prefix = os.getenv("HOME") .. "/notes/",
|
||||||
|
replace_pattern = {
|
||||||
|
[1] = { ['@'] = '_AT_' },
|
||||||
|
[2] = { ['[.]'] = '_DOT_' },
|
||||||
|
[3] = { ['[%$]'] = '_DOLLAR_' },
|
||||||
|
[4] = { ['%~'] = '_TILDE_' },
|
||||||
|
[5] = { ['[%|]'] = '_PIPE_' },
|
||||||
|
[6] = { ['[^a-zA-Z0-9-]'] = '_' },
|
||||||
|
[7] = { ['__+'] = '_' },
|
||||||
|
[8] = { ['^_'] = '' },
|
||||||
|
[9] = { ['_$'] = '' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local function hexdecode(hex)
|
||||||
|
return (hex:gsub("%x%x", function(digits) return string.char(tonumber(digits, 16)) end))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function hexencode(str)
|
||||||
|
return (string.upper(str:gsub(".", function(char) return string.format("%2x", char:byte()) end)))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function dirLookup(dir)
|
||||||
|
local files = {}
|
||||||
|
local p = io.popen('find "' .. dir .. '" -type f') --Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files.
|
||||||
|
if p then
|
||||||
|
for file in p:lines() do --Loop through all files
|
||||||
|
if file:match('.*norg$') then
|
||||||
|
table.insert(files, file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return files
|
||||||
|
end
|
||||||
|
|
||||||
|
local function isempty(s)
|
||||||
|
return s == nil or s == ''
|
||||||
|
end
|
||||||
|
|
||||||
|
local createfilename = function(suffix)
|
||||||
|
local name = vim.fn.input("Please enter a title: ")
|
||||||
|
if string.len(name) == 0 then
|
||||||
|
print(" ")
|
||||||
|
print("Title missing: request ignored!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local date = os.date(M.config_values.dateformat)
|
||||||
|
for index, pv in ipairs(M.config_values.replace_pattern) do
|
||||||
|
for key, value in pairs(pv) do
|
||||||
|
if name.find(name, key) then
|
||||||
|
name = string.gsub(name, key, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return M.config_values.prefix .. date .. name .. suffix, date, name
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.newNeorgNote()
|
||||||
|
local name, date, title = createfilename(".norg")
|
||||||
|
local template = {
|
||||||
|
"* " .. string.gsub(title or "", "_", " "),
|
||||||
|
" ",
|
||||||
|
}
|
||||||
|
vim.cmd(":e" .. name)
|
||||||
|
vim.api.nvim_buf_set_text(0, 0, 0, 0, 0, template)
|
||||||
|
vim.cmd(":Neorg inject-metadata")
|
||||||
|
vim.cmd('startinsert!')
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.newMarkdownNote()
|
||||||
|
local name, date, title = createfilename(".md")
|
||||||
|
local template = {
|
||||||
|
"---",
|
||||||
|
"title: " .. date .. title,
|
||||||
|
"description: ",
|
||||||
|
"authors:",
|
||||||
|
" - nige",
|
||||||
|
"categories:",
|
||||||
|
"project: ",
|
||||||
|
"created: " .. os.date('%Y-%m-%d'),
|
||||||
|
"version: na",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"# " .. string.gsub(title or "", "_", " "),
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
}
|
||||||
|
vim.cmd(":e" .. name)
|
||||||
|
vim.api.nvim_buf_set_text(0, 0, 0, 0, 0, template)
|
||||||
|
vim.cmd('startinsert!')
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.createWorknote()
|
||||||
|
local date = os.date('%Y-%m-%d %H:%M')
|
||||||
|
vim.cmd(':normal o')
|
||||||
|
local pos = vim.api.nvim_win_get_cursor(0)[2]
|
||||||
|
local line = vim.api.nvim_get_current_line()
|
||||||
|
local nline = line:sub(0, pos) .. '- Note tagen on /' .. date .. "/: " .. line:sub(pos + 1)
|
||||||
|
vim.api.nvim_set_current_line(nline)
|
||||||
|
vim.cmd(':normal $')
|
||||||
|
vim.api.nvim_set_mode = 'i'
|
||||||
|
vim.cmd('startinsert!')
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local index = "notes"
|
||||||
|
|
||||||
|
local fillqflist = function(items, query)
|
||||||
|
local title = "Meilisearch - index: '" .. index .. "'"
|
||||||
|
if type(query) ~= "nil" then
|
||||||
|
title = title .. ", query: '" .. query .. "'"
|
||||||
|
end
|
||||||
|
vim.fn.setqflist(
|
||||||
|
{},
|
||||||
|
' ', -- 'a' to add item(s) to an existing list
|
||||||
|
{
|
||||||
|
title = title,
|
||||||
|
id = 999,
|
||||||
|
items = items
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.search()
|
||||||
|
local query = vim.fn.input("Meilisearch: ")
|
||||||
|
local curl = require "plenary.curl"
|
||||||
|
local json = require('json')
|
||||||
|
local prefix = M.config_values.prefix
|
||||||
|
local hits = {}
|
||||||
|
-- print("----" .. query)
|
||||||
|
|
||||||
|
local res = curl.get(M.config_values.server .. "/indexes/notes/search", {
|
||||||
|
accept = "application/json",
|
||||||
|
query = {
|
||||||
|
q = query,
|
||||||
|
showMatchesPosition = "true"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if res then
|
||||||
|
local tab = json.parse(res.body)
|
||||||
|
if tab and type(tab['hits']) ~= "nil" then
|
||||||
|
for i, v in ipairs(tab['hits']) do
|
||||||
|
local hit = {
|
||||||
|
text = "",
|
||||||
|
pattern = query,
|
||||||
|
filename = prefix .. v['title'],
|
||||||
|
-- filename = prefix .. hexdecode(v['id']),
|
||||||
|
}
|
||||||
|
--print("id: '" .. hexdecode(v['id']) .. "'")
|
||||||
|
table.insert(hits, hit)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("No data in table")
|
||||||
|
end
|
||||||
|
|
||||||
|
fillqflist(hits, query)
|
||||||
|
vim.cmd("copen")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local function i(value)
|
||||||
|
print(vim.inspect(value))
|
||||||
|
end
|
||||||
|
|
||||||
|
local removeLines = function(str, lines)
|
||||||
|
local multistring = str
|
||||||
|
for ii = 1, lines, 1 do
|
||||||
|
multistring = multistring:gsub("^[^\n]*\n", "")
|
||||||
|
end
|
||||||
|
return multistring
|
||||||
|
end
|
||||||
|
|
||||||
|
local keywords = {
|
||||||
|
["title"] = false,
|
||||||
|
["description"] = false,
|
||||||
|
["authors"] = true,
|
||||||
|
["categories"] = true,
|
||||||
|
["project"] = false,
|
||||||
|
["created"] = false,
|
||||||
|
["version"] = false
|
||||||
|
}
|
||||||
|
local contains = function(array, val)
|
||||||
|
for k, v in pairs(array) do
|
||||||
|
if k == val then
|
||||||
|
return true, v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false, false
|
||||||
|
end
|
||||||
|
local function splitValue(s, delimiter)
|
||||||
|
local result = {};
|
||||||
|
for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do
|
||||||
|
table.insert(result, match);
|
||||||
|
end
|
||||||
|
return result;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function trim(s)
|
||||||
|
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function trimTable(t)
|
||||||
|
local newTable = {}
|
||||||
|
for key, value in pairs(t) do
|
||||||
|
if type(value) == "string" then
|
||||||
|
newTable[key] = trim(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return newTable
|
||||||
|
end
|
||||||
|
|
||||||
|
local split = function(lines)
|
||||||
|
local metadata = {}
|
||||||
|
for line in lines:gmatch("[^\n]*\n?") do
|
||||||
|
local key = string.match(line, "^[^:]+:")
|
||||||
|
if type(key) ~= "nil" then
|
||||||
|
key = string.sub(key, 1, key:len() - 1)
|
||||||
|
local isContained, isArray = contains(keywords, key:lower())
|
||||||
|
if isContained then
|
||||||
|
local value = string.match(line, ":.*$")
|
||||||
|
if type(value) == "string" then
|
||||||
|
value = string.match(value, "[^: ]+.*$")
|
||||||
|
value = string.gsub(value, "\n", "")
|
||||||
|
if isArray then
|
||||||
|
value = splitValue(value, ",")
|
||||||
|
value = trimTable(value)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
value = ""
|
||||||
|
if isArray then
|
||||||
|
value = { "" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
metadata[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return metadata
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.upsertNote(bufnr)
|
||||||
|
if isempty(bufnr) then
|
||||||
|
bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- local language_tree = vim.treesitter.get_parser(bufnr, 'norg')
|
||||||
|
local language_tree = vim.treesitter.get_parser(bufnr)
|
||||||
|
local syntax_tree = language_tree:parse()
|
||||||
|
local root = syntax_tree[1]:root()
|
||||||
|
|
||||||
|
local query = vim.treesitter.parse_query('norg', [[
|
||||||
|
(ranged_tag
|
||||||
|
name: (tag_name) @name (#eq? @name "document.meta")
|
||||||
|
content: (ranged_tag_content) @content
|
||||||
|
(ranged_tag_end) @end (#offset! @end)
|
||||||
|
)
|
||||||
|
]])
|
||||||
|
|
||||||
|
local header_lines = 0
|
||||||
|
local note
|
||||||
|
for s, captures, metadata in query:iter_matches(root, bufnr) do
|
||||||
|
local headerText = q.get_node_text(captures[2], bufnr)
|
||||||
|
note = split(headerText)
|
||||||
|
local text = q.get_node_text(captures[2], bufnr)
|
||||||
|
|
||||||
|
print('######### s')
|
||||||
|
tprint(s)
|
||||||
|
print('######### captures')
|
||||||
|
tprint(captures)
|
||||||
|
print('######### metadata')
|
||||||
|
tprint(metadata)
|
||||||
|
print('#########')
|
||||||
|
|
||||||
|
header_lines = metadata['ranged_verbatim_tag'][1][1]
|
||||||
|
end
|
||||||
|
-- if header_lines then
|
||||||
|
-- note["headerlines"] = header_lines
|
||||||
|
-- end
|
||||||
|
note["id"] = hexencode(string.gsub(vim.api.nvim_buf_get_name(bufnr), M.config_values.prefix, ""))
|
||||||
|
note["body"] = removeLines(q.get_node_text(root, bufnr), header_lines)
|
||||||
|
--i(note)
|
||||||
|
|
||||||
|
local curl = require "plenary.curl"
|
||||||
|
local json = require('json')
|
||||||
|
local prefix = "/Users/nige/notes/"
|
||||||
|
local hits = {}
|
||||||
|
local header = {}
|
||||||
|
header = { header = "\"Content-Type\" = \"application/json\"" }
|
||||||
|
|
||||||
|
i(curl.post(M.config_values.server .. "/indexes/notes/documents",
|
||||||
|
{ raw = { "-H", "Content-Type: application/json" }, body = json.stringify(note) }
|
||||||
|
))
|
||||||
|
return tonumber(bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.updateAll = function()
|
||||||
|
local files = dirLookup(M.config_values.prefix)
|
||||||
|
for key, value in pairs(files) do
|
||||||
|
if value:match(".*norg") then
|
||||||
|
vim.cmd("e " .. value)
|
||||||
|
local bufnr = M.upsertNote()
|
||||||
|
--vim.cmd("bw")
|
||||||
|
--print("number:" .. bufnr .. type(bufnr))
|
||||||
|
--[[ pcall(vim.api.nvim_buf_delete, bufnr {}) ]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--M.yaml = function()
|
||||||
|
-- print ("START")
|
||||||
|
-- local yaml_string = [[
|
||||||
|
--title
|
||||||
|
-- list
|
||||||
|
-- - item 1
|
||||||
|
-- - item 2
|
||||||
|
-- - item 3
|
||||||
|
-- key: value
|
||||||
|
-- ]]
|
||||||
|
-- print ("load require")
|
||||||
|
-- local yaml = require("lyaml")
|
||||||
|
-- print ("load table")
|
||||||
|
-- local tbl = yaml.load(yaml_string)
|
||||||
|
-- print ("print values")
|
||||||
|
-- print(tbl.title.list)
|
||||||
|
-- print(tbl.title.key)
|
||||||
|
--end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
@ -0,0 +1,23 @@
|
|||||||
|
local neorgAutoCmd = vim.api.nvim_create_augroup("NeorgConcealLevel", { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
|
group = neorgAutoCmd,
|
||||||
|
callback = function()
|
||||||
|
if vim.bo.filetype == "norg" or vim.bo.filetype == "markdown" then
|
||||||
|
io.popen("updateNotes.sh &>/dev/null")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
desc = "Trigger meilisearch update via bash script",
|
||||||
|
})
|
||||||
|
|
||||||
|
local fluxAutoCmd = vim.api.nvim_create_augroup("FluxTask", {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||||
|
group = fluxAutoCmd,
|
||||||
|
callback = function()
|
||||||
|
if vim.fn.expand("%:e") == "flux" then
|
||||||
|
vim.opt.filetype = "flux"
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
desc = "Trigger meilisearch update via bash script",
|
||||||
|
})
|
@ -0,0 +1,62 @@
|
|||||||
|
local lspconfig = require 'lspconfig'
|
||||||
|
local configs = require 'lspconfig.configs'
|
||||||
|
local util = require 'lspconfig.util'
|
||||||
|
|
||||||
|
local env = {
|
||||||
|
HOME = vim.loop.os_homedir(),
|
||||||
|
XDG_CACHE_HOME = os.getenv 'XDG_CACHE_HOME',
|
||||||
|
JDTLS_JVM_ARGS = os.getenv 'JDTLS_JVM_ARGS',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local function get_cache_dir()
|
||||||
|
return env.XDG_CACHE_HOME and env.XDG_CACHE_HOME or lspconfig.util.path.join(env.HOME, '.cache')
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_jdtls_cache_dir()
|
||||||
|
return lspconfig.util.path.join(get_cache_dir(), 'jdtls')
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_jdtls_workspace_dir()
|
||||||
|
return lspconfig.util.path.join(get_jdtls_cache_dir(), 'workspace')
|
||||||
|
end
|
||||||
|
|
||||||
|
local root_files = {
|
||||||
|
-- Single-module projects
|
||||||
|
{
|
||||||
|
'build.xml', -- Ant
|
||||||
|
'pom.xml', -- Maven
|
||||||
|
'settings.gradle', -- Gradle
|
||||||
|
'settings.gradle.kts', -- Gradle
|
||||||
|
},
|
||||||
|
-- Multi-module projects
|
||||||
|
{ 'build.gradle', 'build.gradle.kts' },
|
||||||
|
}
|
||||||
|
if not configs.camel then
|
||||||
|
configs.camel = {
|
||||||
|
default_config = {
|
||||||
|
cmd = { "java", "-jar", "/Users/nige/.local/share/lsp/camel-lsp-server/camel-lsp-server-1.5.0.jar" },
|
||||||
|
filetypes = { 'java' },
|
||||||
|
root_dir = function(fname)
|
||||||
|
for _, patterns in ipairs(root_files) do
|
||||||
|
local root = util.root_pattern(unpack(patterns))(fname)
|
||||||
|
if root then
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
single_file_support = true,
|
||||||
|
init_options = {
|
||||||
|
workspace = get_jdtls_workspace_dir(),
|
||||||
|
jvm_args = {},
|
||||||
|
os_config = nil,
|
||||||
|
},
|
||||||
|
settings = {},
|
||||||
|
},
|
||||||
|
docs = {
|
||||||
|
description = "Language server for ApacheCamel"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
lspconfig.camel.setup {}
|
@ -0,0 +1,80 @@
|
|||||||
|
local cmp = require('cmp')
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
|
||||||
|
local select_opts = { behavior = cmp.SelectBehavior.Select }
|
||||||
|
local has_words_before = function()
|
||||||
|
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
local line, col = table.unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and
|
||||||
|
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col,
|
||||||
|
col)
|
||||||
|
:match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
enabled = true,
|
||||||
|
preselect = cmp.PreselectMode.None,
|
||||||
|
snippet = { expand = function(args) luasnip.lsp_expand(args.body) end },
|
||||||
|
sources = {
|
||||||
|
{ name = 'path' }, { name = 'nvim_lsp' },
|
||||||
|
-- { name = 'buffer', keyword_length = 3 },
|
||||||
|
{ name = 'buffer' }, { name = 'luasnip', keyword_length = 3 },
|
||||||
|
-- { name = 'cmdline' },
|
||||||
|
{ name = "cmp_tabnine" }, { name = "nvim_lua" },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
{ name = "neorg" },
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(select_opts),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(select_opts),
|
||||||
|
['<Tab>'] = cmp.mapping.select_next_item(select_opts),
|
||||||
|
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
['<Enter>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-d>'] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(1) then
|
||||||
|
luasnip.jump(1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
['<C-b>'] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' })
|
||||||
|
}),
|
||||||
|
window = { documentation = cmp.config.window.bordered() },
|
||||||
|
formatting = {
|
||||||
|
fields = { 'menu', 'abbr', 'kind' },
|
||||||
|
format = function(entry, item)
|
||||||
|
local menu_icon = {
|
||||||
|
nvim_lsp = '[lsp]',
|
||||||
|
luasnip = '[snip]',
|
||||||
|
buffer = '[buf]',
|
||||||
|
path = '[path]',
|
||||||
|
--cmdline = "[cmd]",
|
||||||
|
cmp_tabnine = "[tab]",
|
||||||
|
}
|
||||||
|
|
||||||
|
item.menu = menu_icon[entry.source.name]
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = { { name = 'buffer' } }
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } })
|
||||||
|
})
|
@ -0,0 +1,68 @@
|
|||||||
|
local dap = require('dap')
|
||||||
|
dap.adapters.bashdb = {
|
||||||
|
type = 'executable',
|
||||||
|
command = vim.fn.stdpath("data") ..
|
||||||
|
'/mason/packages/bash-debug-adapter/bash-debug-adapter',
|
||||||
|
name = 'bashdb'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dap.configurations.sh = {
|
||||||
|
{
|
||||||
|
type = 'bashdb',
|
||||||
|
request = 'launch',
|
||||||
|
name = "Launch file",
|
||||||
|
showDebugOutput = true,
|
||||||
|
pathBashdb = vim.fn.stdpath("data") ..
|
||||||
|
'/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb',
|
||||||
|
pathBashdbLib = vim.fn.stdpath("data") ..
|
||||||
|
'/mason/packages/bash-debug-adapter/extension/bashdb_dir',
|
||||||
|
trace = true,
|
||||||
|
file = "${file}",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = '${workspaceFolder}',
|
||||||
|
pathCat = "cat",
|
||||||
|
pathBash = "/opt/homebrew/bin/bash",
|
||||||
|
pathMkfifo = "mkfifo",
|
||||||
|
pathPkill = "pkill",
|
||||||
|
args = {},
|
||||||
|
env = {},
|
||||||
|
terminalKind = "integrated",
|
||||||
|
autoReload = { enable = true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.adapters.java = function(callback)
|
||||||
|
-- FIXME:
|
||||||
|
-- Here a function needs to trigger the `vscode.java.startDebugSession` LSP command
|
||||||
|
-- The response to the command must be the `port` used below
|
||||||
|
callback({ type = 'server', host = '127.0.0.1', port = 5005 })
|
||||||
|
end
|
||||||
|
dap.configurations.java = {
|
||||||
|
{
|
||||||
|
type = 'java',
|
||||||
|
request = 'attach',
|
||||||
|
name = "Debug (Attach) - Remote",
|
||||||
|
hostName = "127.0.0.1",
|
||||||
|
port = 5005
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require("dapui").setup({
|
||||||
|
controls = {
|
||||||
|
-- Requires Neovim nightly (or 0.8 when released)
|
||||||
|
enabled = true,
|
||||||
|
-- Display controls in this element
|
||||||
|
element = "repl",
|
||||||
|
icons = {
|
||||||
|
pause = '⏸',
|
||||||
|
play = '⏵',
|
||||||
|
step_into = '↓',
|
||||||
|
step_over = '.⃕',
|
||||||
|
step_out = '↑',
|
||||||
|
step_back = '←',
|
||||||
|
run_last = '↻',
|
||||||
|
terminate = '⏹'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,25 @@
|
|||||||
|
# DAP Normal commands
|
||||||
|
|
||||||
|
<!--toc:start-->
|
||||||
|
- [DAP Normal commands](#dap-normal-commands)
|
||||||
|
<!--toc:end-->
|
||||||
|
|
||||||
|
|
||||||
|
Toggle DAP ui
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require("dapui").toggle()
|
||||||
|
```
|
||||||
|
|
||||||
|
Add argument to bash script
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lua require('dap').configurations.sh[1]['args'] = {"This is a variable"}
|
||||||
|
```
|
||||||
|
|
||||||
|
```vim
|
||||||
|
DapStepOver
|
||||||
|
DapToggleBreakpoint
|
||||||
|
DapContinue
|
||||||
|
DapStepInto
|
||||||
|
```
|
@ -0,0 +1,59 @@
|
|||||||
|
require("setup/plugins")
|
||||||
|
require("setup/set")
|
||||||
|
require("setup/remap")
|
||||||
|
require("setup/camel")
|
||||||
|
require("setup/lsp")
|
||||||
|
require("setup/cmp")
|
||||||
|
require("setup/dap")
|
||||||
|
require("setup/autocmd")
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
insert_business_strategy_meeting_agenda_template = function()
|
||||||
|
local date = os.date("%Y-%m-%d")
|
||||||
|
local template = [[
|
||||||
|
---
|
||||||
|
title: Business Strategy Meeting Agenda
|
||||||
|
date: ]] .. date .. [[
|
||||||
|
location: [Insert location or virtual meeting link]
|
||||||
|
attendees: [Insert names of attendees]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Agenda
|
||||||
|
|
||||||
|
1. Introductions
|
||||||
|
- Welcome and introductions
|
||||||
|
|
||||||
|
2. Review of Previous Meeting
|
||||||
|
- Review and approval of previous meeting minutes
|
||||||
|
- Action items from previous meeting
|
||||||
|
|
||||||
|
3. SWOT Analysis
|
||||||
|
- Strengths, weaknesses, opportunities, and threats
|
||||||
|
- Potential opportunities for growth
|
||||||
|
|
||||||
|
4. Strategic Planning
|
||||||
|
- Key strategic initiatives for growth and success
|
||||||
|
- Action plans and timelines
|
||||||
|
|
||||||
|
5. Resource Allocation
|
||||||
|
- Budget, personnel, and technology allocation for strategic initiatives
|
||||||
|
- Identification of potential gaps or constraints
|
||||||
|
|
||||||
|
6. Risk Management
|
||||||
|
- Identification and assessment of potential risks associated with strategic initiatives
|
||||||
|
- Development of risk mitigation and contingency plans
|
||||||
|
|
||||||
|
7. Next Steps and Adjournment
|
||||||
|
- Recap of action items and next steps
|
||||||
|
- Meeting adjournment
|
||||||
|
]]
|
||||||
|
local lines = vim.split(template, "\n", true)
|
||||||
|
local bufname = vim.fn.bufname() -- get the name of the buffer being deleted
|
||||||
|
vim.api.nvim_buf_delete(0, {}) -- delete current buffer
|
||||||
|
vim.api.nvim_create_buf(false, true) -- create new buffer
|
||||||
|
vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) -- set new buffer content
|
||||||
|
vim.api.nvim_buf_set_name(0, bufname) -- set new buffer name to the deleted buffer's name
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd(
|
||||||
|
"command! -nargs=0 InsertBusinessStrategyMeetingAgendaTemplate lua insert_business_strategy_meeting_agenda_template")
|
@ -0,0 +1,93 @@
|
|||||||
|
require('lspconfig')['jdtls'].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
-- Server-specific settings...
|
||||||
|
settings = {
|
||||||
|
["jdtls"] = {
|
||||||
|
-- The command that starts the language server
|
||||||
|
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
|
||||||
|
|
||||||
|
autostart = true,
|
||||||
|
-- autostart = false,
|
||||||
|
cmd = {
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
'java', -- or '/path/to/java17_or_newer/bin/java'
|
||||||
|
-- depends on if `java` is in your $PATH env variable and if it points to the right version.
|
||||||
|
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||||
|
'-Dosgi.bundles.defaultStartLevel=4',
|
||||||
|
'-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||||
|
'-Dlog.protocol=true', '-Dlog.level=ALL', '-Xms1g',
|
||||||
|
'--add-modules=ALL-SYSTEM', '--add-opens',
|
||||||
|
'java.base/java.util=ALL-UNNAMED', '--add-opens',
|
||||||
|
'java.base/java.lang=ALL-UNNAMED', -- 💀
|
||||||
|
'-jar',
|
||||||
|
'/Users/nige/.local/share/lsp/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar',
|
||||||
|
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
||||||
|
-- Must point to the Change this to
|
||||||
|
-- eclipse.jdt.ls installation the actual version
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
'-configuration',
|
||||||
|
'/Users/nige/.local/share/lsp/jdtls/config_mac',
|
||||||
|
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||||
|
-- Must point to the Change to one of `linux`, `win` or `mac`
|
||||||
|
-- eclipse.jdt.ls installation Depending on your system.
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
'-data', '/Users/nige/.config/jdtls_workspaces/' ..
|
||||||
|
vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||||
|
},
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
-- This is the default if not provided, you can remove it. Or adjust as needed.
|
||||||
|
-- One dedicated LSP server & client will be started per unique root_dir
|
||||||
|
root_dir = require('jdtls.setup').find_root({
|
||||||
|
'.git', 'mvnw', 'gradlew'
|
||||||
|
}),
|
||||||
|
|
||||||
|
-- 💀
|
||||||
|
-- This is the default if not provided, you can remove it. Or adjust as needed.
|
||||||
|
-- One dedicated LSP server & client will be started per unique root_dir
|
||||||
|
|
||||||
|
-- Here you can configure eclipse.jdt.ls specific settings
|
||||||
|
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||||
|
-- for a list of options
|
||||||
|
settings = {
|
||||||
|
java = {
|
||||||
|
eclipse = { downloadSources = true },
|
||||||
|
maven = { downloadSources = true },
|
||||||
|
implementationsCodeLens = { enabled = true },
|
||||||
|
referencesCodeLens = { enabled = true },
|
||||||
|
references = { includeDecompiledSources = true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Language server `initializationOptions`
|
||||||
|
-- You need to extend the `bundles` with paths to jar files
|
||||||
|
-- if you want to use additional eclipse.jdt.ls plugins.
|
||||||
|
--
|
||||||
|
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
|
||||||
|
--
|
||||||
|
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
|
||||||
|
init_options = {
|
||||||
|
extendedClientCapabilities = { classFileContentsSupport = true },
|
||||||
|
bundles = {
|
||||||
|
vim.fn.glob(
|
||||||
|
"/Users/nige/.local/share/nvim/dap-servers/com.microsoft.java.debug.plugin_0.43.0.jar",
|
||||||
|
1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
-- With `hotcodereplace = 'auto' the debug adapter will try to apply code changes
|
||||||
|
-- you make during a debug session immediately.
|
||||||
|
-- Remove the option if you do not want that.
|
||||||
|
-- You can use the `JdtHotcodeReplace` command to trigger it manually
|
||||||
|
-- require('jdtls').setup_dap({ hotcodereplace = 'auto' })
|
||||||
|
local jdtls = require('jdtls')
|
||||||
|
jdtls.setup_dap({ hotcodereplace = 'auto' })
|
||||||
|
jdtls.setup.add_commands()
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
require("mason-lspconfig").setup()
|
||||||
|
|
||||||
|
local addDesc = function(t, v)
|
||||||
|
t["desc"] = v
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
local default_on_attach = function(client, bufnr)
|
||||||
|
client.server_capabilities.document_formatting = false
|
||||||
|
client.server_capabilities.document_range_formatting = false
|
||||||
|
local opts = { buffer = bufnr, remap = false }
|
||||||
|
|
||||||
|
if client.name == "eslint" then
|
||||||
|
vim.cmd.LspStop("eslint")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, addDesc(opts, "Go to definition"))
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, addDesc(opts, "Show Hint"))
|
||||||
|
vim.keymap.set("n", "gD", vim.diagnostic.setqflist, addDesc(opts, "Show diagnostics"))
|
||||||
|
vim.keymap.set("n", "<leader>vws", vim.lsp.buf.workspace_symbol, addDesc(opts, "Query workspace"))
|
||||||
|
vim.keymap.set("n", "<leader>vd", vim.diagnostic.open_float, addDesc(opts, "Open diagnostics"))
|
||||||
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_next, addDesc(opts, "Go to next diagnostics item"))
|
||||||
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, addDesc(opts, "Go to previous diagnostics item"))
|
||||||
|
vim.keymap.set("n", "<leader>vca", vim.lsp.buf.code_action, addDesc(opts, "Code action"))
|
||||||
|
-- vim.keymap.set("n", "<F3>", vim.lsp.buf.code_action,
|
||||||
|
vim.keymap.set("n", "<F3>", ":CodeActionMenu<CR>", addDesc(opts, "Code action"))
|
||||||
|
vim.keymap.set("n", "<leader>vrr", vim.lsp.buf.references, addDesc(opts, "Go to reference"))
|
||||||
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, addDesc(opts, "Go to reference"))
|
||||||
|
vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, addDesc(opts, "Rename"))
|
||||||
|
vim.keymap.set("n", "<F2>", vim.lsp.buf.rename, addDesc(opts, "Rename"))
|
||||||
|
vim.keymap.set("i", "<C-h>", vim.lsp.buf.signature_help, addDesc(opts, "Get signature help"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local default_capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
|
lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, {
|
||||||
|
on_attach = default_on_attach,
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
|
require("null-ls")
|
||||||
|
local mason_null_ls = require("mason-null-ls")
|
||||||
|
mason_null_ls.setup({
|
||||||
|
ensure_installed = {
|
||||||
|
-- Opt to list sources here, when available in mason.
|
||||||
|
},
|
||||||
|
automatic_installation = false,
|
||||||
|
automatic_setup = true, -- Recommended, but optional
|
||||||
|
})
|
||||||
|
|
||||||
|
mason_null_ls.setup_handlers()
|
||||||
|
|
||||||
|
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
|
require("mason-lspconfig").setup_handlers({
|
||||||
|
function(server_name) -- default handler (optional)
|
||||||
|
require("lspconfig")[server_name].setup({ capabilities = capabilities })
|
||||||
|
end,
|
||||||
|
["lua_ls"] = function()
|
||||||
|
require("lspconfig").lua_ls.setup({
|
||||||
|
settings = { Lua = { diagnostics = { globals = { "vim" } } } },
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
-- float = { show_header = true, souce = "always", border = "rounded", wrap = true, },
|
||||||
|
float = { show_header = true, souce = "always", border = "rounded" },
|
||||||
|
severity_sort = true, -- default to false
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
lspconfig.flux_lsp.setup{}
|
@ -0,0 +1,35 @@
|
|||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
vim.keymap.set("i", "jj", "<ESC>", { desc = "Exit insert mode" })
|
||||||
|
vim.keymap.set("t", "jj", "<C-\\><C-n>", { desc = "Exit terminal input mode" })
|
||||||
|
vim.keymap.set("v", "<", "<gv", { desc = "Undent and mark again" })
|
||||||
|
vim.keymap.set("v", ">", ">gv", { desc = "Indent and mark again" })
|
||||||
|
|
||||||
|
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move markt row(s) down" })
|
||||||
|
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move markt row(s) up" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "J", "mzJ`z", { desc = "Append line below to the current line" })
|
||||||
|
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Page down and center" })
|
||||||
|
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Page up and center" })
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]], { desc = "Yank into system clipboard" })
|
||||||
|
vim.keymap.set("n", "<leader>yy", [["+yy]], { desc = "Yank line into system clipboard" })
|
||||||
|
vim.keymap.set("n", "<leader>p", [["+p]], { desc = "Put text from system clipboard after cursor" })
|
||||||
|
vim.keymap.set("n", "<leader>P", [["+P]], { desc = "Put text from system clipboard before cursor" })
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>d", [["_d]], { desc = "Delete without saving to register" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "Q", "<nop>", { desc = "" })
|
||||||
|
-- vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>", { desc = "" })
|
||||||
|
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format, { desc = "Format current buffer" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz", { desc = "Center on next quickfix item" })
|
||||||
|
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz", { desc = "Center on previous quickfix item" })
|
||||||
|
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Center on next locationlist item" })
|
||||||
|
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Center on previous locationlist item" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Make current file executable" })
|
||||||
|
|
||||||
|
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal input mode" })
|
||||||
|
vim.keymap.set("t", "<M-[>", "<Esc>", { desc = "Exit mode" })
|
||||||
|
vim.keymap.set("t", "<C-v><Esc>", "<Esc>", { desc = "Exit mode" })
|
@ -0,0 +1,34 @@
|
|||||||
|
vim.opt.nu = true
|
||||||
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
|
vim.opt.tabstop = 4
|
||||||
|
vim.opt.softtabstop = 4
|
||||||
|
vim.opt.shiftwidth = 4
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
|
||||||
|
vim.opt.smartindent = true
|
||||||
|
|
||||||
|
--[[ vim.opt.wrap = false ]]
|
||||||
|
vim.opt.swapfile = false
|
||||||
|
vim.opt.backup = false
|
||||||
|
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||||
|
vim.opt.undofile = true
|
||||||
|
|
||||||
|
vim.opt.hlsearch = true
|
||||||
|
vim.opt.incsearch = true
|
||||||
|
|
||||||
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
|
vim.opt.scrolloff = 8
|
||||||
|
vim.opt.signcolumn = "yes"
|
||||||
|
vim.opt.isfname:append("@-@")
|
||||||
|
|
||||||
|
vim.opt.updatetime = 50
|
||||||
|
|
||||||
|
vim.opt.colorcolumn = "80"
|
||||||
|
|
||||||
|
vim.opt.foldlevelstart = 99
|
||||||
|
|
||||||
|
vim.g.vim_markdown_folding_disabled = 1
|
||||||
|
|
||||||
|
vim.g.tick_fmt_autosave = 0
|
@ -0,0 +1,70 @@
|
|||||||
|
-- vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input)
|
||||||
|
-- vim.o.shiftwidth = tonumber(input)
|
||||||
|
-- end)
|
||||||
|
-- vim.ui.select({ 'tabs', 'spaces' }, {
|
||||||
|
-- prompt = 'Select tabs or spaces:',
|
||||||
|
-- format_item = function(item)
|
||||||
|
-- return "I'd like to choose " .. item
|
||||||
|
-- end,
|
||||||
|
-- }, function(choice)
|
||||||
|
-- if choice == 'spaces' then
|
||||||
|
-- vim.o.expandtab = true
|
||||||
|
-- else
|
||||||
|
-- vim.o.expandtab = false
|
||||||
|
-- end
|
||||||
|
-- end)
|
||||||
|
-- function NavigationFloatingWin()
|
||||||
|
-- -- get the editor's max width and height
|
||||||
|
-- local width = vim.api.nvim_get_option("columns")
|
||||||
|
-- local height = vim.api.nvim_get_option("lines")
|
||||||
|
--
|
||||||
|
-- -- create a new, scratch buffer, for fzf
|
||||||
|
-- local buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
-- vim.api.nvim_buf_set_option(buf, 'buftype', 'nofile')
|
||||||
|
--
|
||||||
|
-- -- if the editor is big enough
|
||||||
|
-- if (width > 150 or height > 35) then
|
||||||
|
-- -- fzf's window height is 3/4 of the max height, but not more than 30
|
||||||
|
-- local win_height = math.min(math.ceil(height * 3 / 4), 30)
|
||||||
|
-- local win_width
|
||||||
|
--
|
||||||
|
-- -- if the width is small
|
||||||
|
-- if (width < 150) then
|
||||||
|
-- -- just subtract 8 from the editor's width
|
||||||
|
-- win_width = math.ceil(width - 8)
|
||||||
|
-- else
|
||||||
|
-- -- use 90% of the editor's width
|
||||||
|
-- win_width = math.ceil(width * 0.9)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- -- settings for the fzf window
|
||||||
|
-- local opts = {
|
||||||
|
-- relative = "editor",
|
||||||
|
-- width = win_width,
|
||||||
|
-- height = win_height,
|
||||||
|
-- row = math.ceil((height - win_height) / 2),
|
||||||
|
-- col = math.ceil((width - win_width) / 2)
|
||||||
|
-- }
|
||||||
|
--
|
||||||
|
-- -- create a new floating window, centered in the editor
|
||||||
|
-- local win = vim.api.nvim_open_win(buf, true, opts)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- NavigationFloatingWin()
|
||||||
|
local buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
vim.api.nvim_buf_set_lines(buf, 0, -1, true, {"test", "text"})
|
||||||
|
local opts = {
|
||||||
|
relative = 'editor',
|
||||||
|
-- relative = 'cursor',
|
||||||
|
width = 10,
|
||||||
|
height = 2,
|
||||||
|
col = 60,
|
||||||
|
row = 10,
|
||||||
|
anchor = 'NW',
|
||||||
|
style = 'minimal'
|
||||||
|
}
|
||||||
|
local win = vim.api.nvim_open_win(buf, 0, opts)
|
||||||
|
-- optional: change highlight, otherwise Pmenu is used
|
||||||
|
vim.api.nvim_win_set_option(win, 'winhl', 'Normal:MyHighlight')
|
||||||
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.map(mode, lhs, rhs, opts)
|
||||||
|
local options = { noremap = true }
|
||||||
|
if opts then
|
||||||
|
options = vim.tbl_extend("force", options, opts)
|
||||||
|
end
|
||||||
|
vim.keymap.set(mode, lhs, rhs, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Print contents of `tbl`, with indentation.
|
||||||
|
-- `indent` sets the initial level of indentation.
|
||||||
|
function M.tprint(tbl, indent)
|
||||||
|
if not indent then indent = 0 end
|
||||||
|
if type(tbl) == "table" then
|
||||||
|
for k, v in pairs(tbl) do
|
||||||
|
local formatting = string.rep(" ", indent) .. k .. ": "
|
||||||
|
if type(v) == "table" then
|
||||||
|
--print(string.rep(" ", indent) .. k .. ": ")
|
||||||
|
print(formatting)
|
||||||
|
M.tprint(v, indent + 1)
|
||||||
|
elseif type(v) == "string" then
|
||||||
|
print(formatting .. v)
|
||||||
|
else
|
||||||
|
--print(string.rep(" ", indent) .. k .. ": " .. v)
|
||||||
|
print(formatting .. tostring(v))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif type(tbl) == "string" then
|
||||||
|
print(tbl)
|
||||||
|
else
|
||||||
|
print(tostring(tbl))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.dump(o)
|
||||||
|
if type(o) == 'table' then
|
||||||
|
local s = '{ '
|
||||||
|
for k, v in pairs(o) do
|
||||||
|
if type(k) ~= 'number' then k = '"' .. k .. '"' end
|
||||||
|
s = s .. '[' .. k .. '] = ' .. M.dump(v) .. ','
|
||||||
|
end
|
||||||
|
return s .. '} '
|
||||||
|
else
|
||||||
|
return tostring(o)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.getLine(lines, startCol)
|
||||||
|
local count = 0
|
||||||
|
local currentLine = 0
|
||||||
|
for line in lines:gmatch("[^\n]*\n?") do
|
||||||
|
local currentCount = count + string.len(line) + 2
|
||||||
|
if currentCount >= startCol then
|
||||||
|
local lineStartCol = startCol - count
|
||||||
|
return line, currentLine, lineStartCol
|
||||||
|
else
|
||||||
|
currentLine = currentLine + 1
|
||||||
|
count = currentCount
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -0,0 +1,21 @@
|
|||||||
|
[user]
|
||||||
|
name = Nils Gerstner
|
||||||
|
email = nilsonline@gmail.com
|
||||||
|
|
||||||
|
[includeIf "gitdir:~/Documents/Code/BOLIDEN/"]
|
||||||
|
path = ~/dotfiles/.config/git_custom_configuration/git_replyto_config
|
||||||
|
|
||||||
|
[includeIf "gitdir:~/Documents/Code/REPLYTO/"]
|
||||||
|
path = ~/dotfiles/.config/git_custom_configuration/git_replyto_config
|
||||||
|
|
||||||
|
[includeIf "gitdir:~/Documents/Code/RISE/"]
|
||||||
|
path = ~/dotfiles/.config/git_custom_configuration/git_replyto_config
|
||||||
|
|
||||||
|
[includeIf "gitdir:~/Documents/Code/VOLVOFINANS/"]
|
||||||
|
path = ~/dotfiles/.config/git_custom_configuration/git_replyto_config
|
||||||
|
|
||||||
|
[includeIf "gitdir:~/Documents/Code/VOLVOCARS/"]
|
||||||
|
path = ~/dotfiles/.config/git_custom_configuration/git_vcc_config
|
||||||
|
|
||||||
|
[includeIf "gitdir:~/Documents/Code/GERSTNER/"]
|
||||||
|
path = ~/dotfiles/.config/git_custom_configuration/git_gerstner_config
|
@ -0,0 +1,152 @@
|
|||||||
|
#set -g mouse on
|
||||||
|
#set -g default-terminal "screen-256color"
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Our .tmux.conf file
|
||||||
|
|
||||||
|
# Setting the prefix from C-b to C-a
|
||||||
|
#set -g prefix C-a
|
||||||
|
set -g prefix C-z
|
||||||
|
#
|
||||||
|
# Free the original Ctrl-b prefix keybinding
|
||||||
|
unbind C-b
|
||||||
|
#
|
||||||
|
#setting the delay between prefix and command
|
||||||
|
set -s escape-time 1
|
||||||
|
#
|
||||||
|
# Ensure that we can send Ctrl-A to other apps
|
||||||
|
bind C-a send-prefix
|
||||||
|
|
||||||
|
# Set the base index for windows to 1 instead of 0
|
||||||
|
#set -g base-index 1
|
||||||
|
|
||||||
|
# Set the base index for panes to 1 instead of 0
|
||||||
|
#setw -g pane-base-index 1
|
||||||
|
|
||||||
|
# Set scrollback buffer size to 10000 lines
|
||||||
|
set-option -g history-limit 10000
|
||||||
|
|
||||||
|
# Reload the file with Prefix r
|
||||||
|
bind r source-file ~/.tmux.conf \; display "Reloaded!"
|
||||||
|
|
||||||
|
# splitting panes with | and -
|
||||||
|
bind | split-window -h
|
||||||
|
bind - split-window -v
|
||||||
|
|
||||||
|
# moving between panes with Prefix h,j,k,l
|
||||||
|
bind h select-pane -L
|
||||||
|
bind j select-pane -D
|
||||||
|
bind k select-pane -U
|
||||||
|
bind l select-pane -R
|
||||||
|
|
||||||
|
# Quick window selection
|
||||||
|
bind -r C-h select-window -t :-
|
||||||
|
bind -r C-l select-window -t :+
|
||||||
|
|
||||||
|
# Pane resizing panes with Prefix H,J,K,L
|
||||||
|
bind -r H resize-pane -L 5
|
||||||
|
bind -r J resize-pane -D 5
|
||||||
|
bind -r K resize-pane -U 5
|
||||||
|
bind -r L resize-pane -R 5
|
||||||
|
|
||||||
|
# mouse support - set to on if you want to use the mouse
|
||||||
|
#set -g mouse off
|
||||||
|
|
||||||
|
# Set the default terminal mode to 256color mode
|
||||||
|
set -g default-terminal "screen-256color"
|
||||||
|
|
||||||
|
#set -g status-bg blue
|
||||||
|
#set -g status-fg white
|
||||||
|
|
||||||
|
set -g status-bg colour227
|
||||||
|
set -g status-fg black
|
||||||
|
|
||||||
|
#set -g status-bg colour196
|
||||||
|
#set -g status-fg black
|
||||||
|
|
||||||
|
# set the status line's colors
|
||||||
|
#set -g status-style fg=white,bg=black
|
||||||
|
|
||||||
|
# set the color of the window list
|
||||||
|
#setw -g window-status-style fg=cyan,bg=black
|
||||||
|
|
||||||
|
# set colors for the active window
|
||||||
|
#setw -g window-status-current-style fg=white,bold,bg=red
|
||||||
|
|
||||||
|
# colors for pane borders
|
||||||
|
#setw -g pane-border-style fg=green,bg=black
|
||||||
|
#setw -g pane-active-border-style fg=white,bg=yellow
|
||||||
|
|
||||||
|
# active pane normal, other shaded out
|
||||||
|
#setw -g window-style fg=colour240,bg=colour235
|
||||||
|
#setw -g window-active-style fg=white,bg=colour16
|
||||||
|
#setw -g window-style fg=colour240,bg=colour235
|
||||||
|
#setw -g window-active-style fg=whith,bg=black
|
||||||
|
|
||||||
|
# Command / message line
|
||||||
|
#setw -g message-style fg=white,bold,bg=black
|
||||||
|
|
||||||
|
# Status line left side to show Session:window:pane
|
||||||
|
set -g status-left-length 40
|
||||||
|
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
|
||||||
|
|
||||||
|
# Status line right side - 50% | 31 Oct 13:37
|
||||||
|
set -g status-right "#(~/battery Discharging) | #[fg=black]%d %b %R"
|
||||||
|
|
||||||
|
# Update the status line every sixty seconds
|
||||||
|
set -g status-interval 60
|
||||||
|
|
||||||
|
# Center the window list in the status line
|
||||||
|
set -g status-justify centre
|
||||||
|
|
||||||
|
# enable activity alerts
|
||||||
|
setw -g monitor-activity on
|
||||||
|
set -g visual-activity on
|
||||||
|
|
||||||
|
# enable vi keys.
|
||||||
|
setw -g mode-keys vi
|
||||||
|
|
||||||
|
# escape turns on copy mode
|
||||||
|
#bind Escape copy-mode-vi
|
||||||
|
|
||||||
|
# v in copy mode starts making selection
|
||||||
|
#bind-key -T copy-mode-vi v send -X begin-selection
|
||||||
|
|
||||||
|
# make Prefix p paste the buffer.
|
||||||
|
unbind p
|
||||||
|
bind p paste-buffer
|
||||||
|
|
||||||
|
# shortcut for synchronize-panes toggle
|
||||||
|
bind C-s set-window-option synchronize-panes
|
||||||
|
|
||||||
|
# split pane and retain the current directory of existing pane
|
||||||
|
bind _ split-window -v -c "#{pane_current_path}"
|
||||||
|
bind \ split-window -h -c "#{pane_current_path}"
|
||||||
|
|
||||||
|
# Log output to a text file on demand
|
||||||
|
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"
|
||||||
|
#
|
||||||
|
# Load mac-specific settings
|
||||||
|
if-shell "uname | grep -q Darwin" "source-file ~/.tmux.mac.conf"
|
||||||
|
|
||||||
|
# load private settings if they exist
|
||||||
|
if-shell "[ -f ~/.tmux.private]" "source ~/.tmux.private"
|
||||||
|
|
||||||
|
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||||
|
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
|
||||||
|
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
||||||
|
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
||||||
|
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
||||||
|
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||||
|
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
|
||||||
|
|
||||||
|
bind C-l send-keys 'C-l'
|
||||||
|
|
||||||
|
set-option -g default-shell "/bin/bash"
|
||||||
|
|
||||||
|
set -g @plugin 'tmux-plugins/tpm'
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-yank'
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-logging'
|
||||||
|
|
||||||
|
run -b '~/.tmux/plugins/tpm/tpm'
|
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
exec "~/lua/lua-language-server/bin/lua-language-server" "$@"
|
||||||
|
|
||||||
|
~/lua/lua-language-server
|
Binary file not shown.
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
file=$1
|
||||||
|
neorg-pandoc-linux86 $file | sed "s/\"pandoc-api-version\":\[[0-9]\+,[0-9]\+,[0-9]\+\]/\"pandoc-api-version\":[1,20,0]/" | jq | pandoc -f json -s -t html5 -c ./note.css -o ${file}.html --metadata title="notes"
|
||||||
|
|
||||||
|
#neorg-pandoc-linux86 $file | sed "s/\"pandoc-api-version\":\[[0-9]\+,[0-9]\+,[0-9]\+\]/\"pandoc-api-version\":[1,20,0]/" | jq | pandoc -f json -s -t markdown -o ${file}.md
|
||||||
|
neorg-pandoc-linux86 $file | sed "s/\"pandoc-api-version\":\[[0-9]\+,[0-9]\+,[0-9]\+\]/\"pandoc-api-version\":[1,20,0]/" | jq | pandoc -f json -s -t markdown_mmd -o ${file}.md
|
@ -0,0 +1,11 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
|
||||||
|
source_file="$1"; shift;
|
||||||
|
format="${2:-html5}"; shift;
|
||||||
|
echo "$@"
|
||||||
|
|
||||||
|
neorg-pandoc-linux86 "${source_file}" | \
|
||||||
|
sed "s/\"pandoc-api-version\":\[[0-9]\+,[0-9]\+,[0-9]\+\]/\"pandoc-api-version\":[1,20,0]/" | \
|
||||||
|
|
||||||
|
#jq | \
|
||||||
|
#pandoc -f json -w "${format}" $@
|
@ -0,0 +1,95 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
|
||||||
|
MEILISEARCH_URL=http://localhost:7700
|
||||||
|
INDEXNAME=notes
|
||||||
|
|
||||||
|
# true << DROP
|
||||||
|
echo "DROP"
|
||||||
|
curl -s -X DELETE "${MEILISEARCH_URL}/indexes/${INDEXNAME}/documents"
|
||||||
|
echo
|
||||||
|
sleep 5
|
||||||
|
# DROP
|
||||||
|
|
||||||
|
|
||||||
|
# true << CREATE
|
||||||
|
echo "CREATE"
|
||||||
|
curl -s -X POST "${MEILISEARCH_URL}/indexes" -H "Content-Type: application/json" --data-binary "{
|
||||||
|
\"uid\": \"${INDEXNAME}\",
|
||||||
|
\"primaryKey\": \"id\"
|
||||||
|
}"
|
||||||
|
echo
|
||||||
|
sleep 5
|
||||||
|
# CREATE
|
||||||
|
|
||||||
|
# true << UPDATE_SETTINGS
|
||||||
|
echo "UPDATE SETTINGS"
|
||||||
|
curl -s -X PATCH "${MEILISEARCH_URL}/indexes/${INDEXNAME}/settings" -vvv -H 'Content-Type: application/json' --data-binary '{
|
||||||
|
"rankingRules": [
|
||||||
|
"words",
|
||||||
|
"typo",
|
||||||
|
"proximity",
|
||||||
|
"attribute",
|
||||||
|
"exactness",
|
||||||
|
"refcount:desc",
|
||||||
|
"changed:desc",
|
||||||
|
"created:desc"
|
||||||
|
],
|
||||||
|
"filterableAttributes": [
|
||||||
|
"tags"
|
||||||
|
],
|
||||||
|
"displayedAttributes": [
|
||||||
|
"title",
|
||||||
|
"tags",
|
||||||
|
"type",
|
||||||
|
"created",
|
||||||
|
"changed",
|
||||||
|
"id",
|
||||||
|
"body",
|
||||||
|
"image",
|
||||||
|
"refcount",
|
||||||
|
"headerlines"
|
||||||
|
],
|
||||||
|
"searchableAttributes": [
|
||||||
|
"tags",
|
||||||
|
"description",
|
||||||
|
"title",
|
||||||
|
"body"
|
||||||
|
],
|
||||||
|
"sortableAttributes": [
|
||||||
|
"refcount",
|
||||||
|
"changed",
|
||||||
|
"created"
|
||||||
|
],
|
||||||
|
"distinctAttribute": "id",
|
||||||
|
"stopWords": null
|
||||||
|
}'
|
||||||
|
echo
|
||||||
|
sleep 5
|
||||||
|
# UPDATE_SETTINGS
|
||||||
|
|
||||||
|
# true << UPDATE_NOTES
|
||||||
|
~/bin/updateNotes.sh all
|
||||||
|
echo
|
||||||
|
sleep 5
|
||||||
|
# UPDATE_NOTES
|
||||||
|
|
||||||
|
#<< SHOW_SETTINGS
|
||||||
|
echo "SHOW SETTINGS"
|
||||||
|
curl -s -X GET 'http://localhost:7700/indexes/notes/settings'| jq
|
||||||
|
echo
|
||||||
|
#SHOW_SETTINGS
|
||||||
|
|
||||||
|
# << SHOW_STATS
|
||||||
|
echo "Neorg and Markdown files found in notes folder: $(ls -1 | grep -e ".*[.]\(norg\|md\)$"| wc -l)"
|
||||||
|
echo
|
||||||
|
echo "SHOW STATS"
|
||||||
|
curl -s 'http://localhost:7700/indexes/notes/stats'| jq
|
||||||
|
echo
|
||||||
|
INDEXNAME="456"
|
||||||
|
# SHOW_STATS
|
||||||
|
|
||||||
|
# << GET_UPDATES
|
||||||
|
echo "GET UPDATES"
|
||||||
|
curl -s 'http://localhost:7700/indexes/notes/updates/'| jq
|
||||||
|
echo
|
||||||
|
# GET_UPDATES
|
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
fast_chr() {
|
||||||
|
local __octal
|
||||||
|
local __char
|
||||||
|
printf -v __octal '%03o' "$1"
|
||||||
|
printf -v __char "\\%s" "$__octal"
|
||||||
|
REPLY=$__char
|
||||||
|
}
|
||||||
|
|
||||||
|
function unichr {
|
||||||
|
local c=$1 # Ordinal of char
|
||||||
|
local l=0 # Byte ctr
|
||||||
|
local o=63 # Ceiling
|
||||||
|
local p=128 # Accum. bits
|
||||||
|
local s='' # Output string
|
||||||
|
|
||||||
|
(( c < 0x80 )) && { fast_chr "$c"; echo -n "$REPLY"; return; }
|
||||||
|
|
||||||
|
while (( c > o )); do
|
||||||
|
fast_chr $(( t = 0x80 | c & 0x3f ))
|
||||||
|
s="$REPLY$s"
|
||||||
|
(( c >>= 6, l++, p += o+1, o>>=1 ))
|
||||||
|
done
|
||||||
|
fast_chr $(( t = p | c ))
|
||||||
|
echo -n " $REPLY$s"
|
||||||
|
}
|
||||||
|
## test harness
|
||||||
|
# for (( i=0x2500; i<0x2600; i++ )); do
|
||||||
|
for (( i=0x0; i<0x20000; i++ )); do
|
||||||
|
unichr "$i"
|
||||||
|
done
|
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash -
|
||||||
|
|
||||||
|
Usage() { echo "$0 FontFile"; exit 1; }
|
||||||
|
SayError() { local error=$1; shift; echo "$0: $*"; exit "$error"; }
|
||||||
|
|
||||||
|
#[ "$#" -ne 1 ] && Usage
|
||||||
|
|
||||||
|
width=70
|
||||||
|
fontfile="$1"
|
||||||
|
echo "$fontfile"
|
||||||
|
[ -f "$fontfile" ] || SayError 4 "File not found: ${fontfile}"
|
||||||
|
|
||||||
|
list=$(fc-query --format='%{charset}\n' "$fontfile")
|
||||||
|
|
||||||
|
for range in $list
|
||||||
|
do IFS=- read start end <<<"$range"
|
||||||
|
# if [ "$end" ]
|
||||||
|
# then
|
||||||
|
# start=$((16#$start))
|
||||||
|
# end=$((16#$end))
|
||||||
|
# for((i=start;i<=end;i++)); do
|
||||||
|
# #printf -v char '\\U%x' "$i"
|
||||||
|
# printf '%b\n' "$char"
|
||||||
|
# done
|
||||||
|
# else
|
||||||
|
printf '%b\n' "\\U${start}"
|
||||||
|
# printf '%b - %b\n' "\\U$start" $char
|
||||||
|
# fi
|
||||||
|
done | cat -e
|
||||||
|
#| ggrep -oP '.{'"$width"'}'
|
@ -0,0 +1,2 @@
|
|||||||
|
echo "username=nils-gg"
|
||||||
|
echo 'password=tcT7-9n2`@\HKQ$n{N{_Y+oPVLS-=K@w$)D*B$MERkDk4yW4%E'
|
@ -0,0 +1,241 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
|
||||||
|
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
|
||||||
|
# only accepts ESC backslash for ST. We use TERM instead of TMUX because TERM
|
||||||
|
# gets passed through ssh.
|
||||||
|
function print_osc() {
|
||||||
|
if [[ $TERM == screen* || $TERM == tmux* ]]; then
|
||||||
|
printf "\033Ptmux;\033\033]"
|
||||||
|
else
|
||||||
|
printf "\033]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# More of the tmux workaround described above.
|
||||||
|
function print_st() {
|
||||||
|
if [[ $TERM == screen* || $TERM == tmux* ]]; then
|
||||||
|
printf "\a\033\\"
|
||||||
|
else
|
||||||
|
printf "\a"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_version() {
|
||||||
|
if [ -z ${IMGCAT_BASE64_VERSION+x} ]; then
|
||||||
|
IMGCAT_BASE64_VERSION=$(base64 --version 2>&1)
|
||||||
|
export IMGCAT_BASE64_VERSION
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function b64_encode() {
|
||||||
|
load_version
|
||||||
|
if [[ $IMGCAT_BASE64_VERSION =~ GNU ]]; then
|
||||||
|
# Disable line wrap
|
||||||
|
base64 -w0
|
||||||
|
else
|
||||||
|
base64
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function b64_decode() {
|
||||||
|
load_version
|
||||||
|
if [[ $IMGCAT_BASE64_VERSION =~ fourmilab ]]; then
|
||||||
|
BASE64ARG=-d
|
||||||
|
elif [[ $IMGCAT_BASE64_VERSION =~ GNU ]]; then
|
||||||
|
BASE64ARG=-di
|
||||||
|
else
|
||||||
|
BASE64ARG=-D
|
||||||
|
fi
|
||||||
|
base64 $BASE64ARG
|
||||||
|
}
|
||||||
|
|
||||||
|
# print_image filename inline base64contents print_filename width height preserve_aspect_ratio
|
||||||
|
# filename: Filename to convey to client
|
||||||
|
# inline: 0 or 1, if set to 1, the file will be displayed inline, otherwise, it will be downloaded
|
||||||
|
# base64contents: Base64-encoded contents
|
||||||
|
# print_filename: 0 or 1, if set to 1, print the filename after outputting the image
|
||||||
|
# width: set output width of the image in character cells, pixels or percent
|
||||||
|
# height: set output height of the image in character cells, pixels or percent
|
||||||
|
# preserve_aspect_ratio: 0 or 1, if set to 1, fill the specified width and height as much as possible without stretching the image
|
||||||
|
# file: Empty string or file type like "application/json" or ".js".
|
||||||
|
function print_image() {
|
||||||
|
print_osc
|
||||||
|
printf "1337;File=inline=%s" "$2"
|
||||||
|
printf ";size=%d" $(printf "%s" "$3" | b64_decode | wc -c)
|
||||||
|
[ -n "$1" ] && printf ";name=%s" "$(printf "%s" "$1" | b64_encode)"
|
||||||
|
[ -n "$5" ] && printf ";width=%s" "$5"
|
||||||
|
[ -n "$6" ] && printf ";height=%s" "$6"
|
||||||
|
[ -n "$7" ] && printf ";preserveAspectRatio=%s" "$7"
|
||||||
|
[ -n "$8" ] && printf ";type=%s" "$8"
|
||||||
|
printf ":%s" "$3"
|
||||||
|
print_st
|
||||||
|
printf '\n'
|
||||||
|
[ "$4" == "1" ] && echo "$1"
|
||||||
|
has_image_displayed=t
|
||||||
|
}
|
||||||
|
|
||||||
|
function error() {
|
||||||
|
errcho "ERROR: $*"
|
||||||
|
}
|
||||||
|
|
||||||
|
function errcho() {
|
||||||
|
echo "$@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_help() {
|
||||||
|
errcho
|
||||||
|
errcho "Usage: imgcat [-p] [-n] [-W width] [-H height] [-r] [-s] [-u] [-t file-type] [-f] filename ..."
|
||||||
|
errcho " cat filename | imgcat [-W width] [-H height] [-r] [-s]"
|
||||||
|
errcho
|
||||||
|
errcho "Display images inline in the iTerm2 using Inline Images Protocol"
|
||||||
|
errcho
|
||||||
|
errcho "Options:"
|
||||||
|
errcho
|
||||||
|
errcho " -h, --help Display help message"
|
||||||
|
errcho " -p, --print Enable printing of filename or URL after each image"
|
||||||
|
errcho " -n, --no-print Disable printing of filename or URL after each image"
|
||||||
|
errcho " -u, --url Interpret following filename arguments as remote URLs"
|
||||||
|
errcho " -f, --file Interpret following filename arguments as regular Files"
|
||||||
|
errcho " -t, --type file-type Provides a type hint"
|
||||||
|
errcho " -r, --preserve-aspect-ratio When scaling image preserve its original aspect ratio"
|
||||||
|
errcho " -s, --stretch Stretch image to specified width and height (this option is opposite to -r)"
|
||||||
|
errcho " -W, --width N Set image width to N character cells, pixels or percent (see below)"
|
||||||
|
errcho " -H, --height N Set image height to N character cells, pixels or percent (see below)"
|
||||||
|
errcho
|
||||||
|
errcho " If you don't specify width or height an appropriate value will be chosen automatically."
|
||||||
|
errcho " The width and height are given as word 'auto' or number N followed by a unit:"
|
||||||
|
errcho " N character cells"
|
||||||
|
errcho " Npx pixels"
|
||||||
|
errcho " N% percent of the session's width or height"
|
||||||
|
errcho " auto the image's inherent size will be used to determine an appropriate dimension"
|
||||||
|
errcho
|
||||||
|
errcho " If a type is provided, it is used as a hint to disambiguate."
|
||||||
|
errcho " The file type can be a mime type like text/markdown, a language name like Java, or a file extension like .c"
|
||||||
|
errcho " The file type can usually be inferred from the extension or its contents. -t is most useful when"
|
||||||
|
errcho " a filename is not available, such as whe input comes from a pipe."
|
||||||
|
errcho
|
||||||
|
errcho "Examples:"
|
||||||
|
errcho
|
||||||
|
errcho " $ imgcat -W 250px -H 250px -s avatar.png"
|
||||||
|
errcho " $ cat graph.png | imgcat -W 100%"
|
||||||
|
errcho " $ imgcat -p -W 500px -u http://host.tld/path/to/image.jpg -W 80 -f image.png"
|
||||||
|
errcho " $ cat url_list.txt | xargs imgcat -p -W 40 -u"
|
||||||
|
errcho " $ imgcat -t application/json config.json"
|
||||||
|
errcho
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_dependency() {
|
||||||
|
if ! (builtin command -V "$1" >/dev/null 2>&1); then
|
||||||
|
error "missing dependency: can't find $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# verify that value is in the image sizing unit format: N / Npx / N% / auto
|
||||||
|
function validate_size_unit() {
|
||||||
|
if [[ ! "$1" =~ ^(:?[0-9]+(:?px|%)?|auto)$ ]]; then
|
||||||
|
error "Invalid image sizing unit - '$1'"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## Main
|
||||||
|
|
||||||
|
if [ -t 0 ]; then
|
||||||
|
has_stdin=f
|
||||||
|
else
|
||||||
|
has_stdin=t
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show help if no arguments and no stdin.
|
||||||
|
if [ $has_stdin = f ] && [ $# -eq 0 ]; then
|
||||||
|
show_help
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_dependency base64
|
||||||
|
check_dependency wc
|
||||||
|
file_type=""
|
||||||
|
|
||||||
|
# Look for command line flags.
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-h | --h | --help)
|
||||||
|
show_help
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-p | --p | --print)
|
||||||
|
print_filename=1
|
||||||
|
;;
|
||||||
|
-n | --n | --no-print)
|
||||||
|
print_filename=0
|
||||||
|
;;
|
||||||
|
-W | --W | --width)
|
||||||
|
validate_size_unit "$2"
|
||||||
|
width="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-H | --H | --height)
|
||||||
|
validate_size_unit "$2"
|
||||||
|
height="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-r | --r | --preserve-aspect-ratio)
|
||||||
|
preserve_aspect_ratio=1
|
||||||
|
;;
|
||||||
|
-s | --s | --stretch)
|
||||||
|
preserve_aspect_ratio=0
|
||||||
|
;;
|
||||||
|
-f | --f | --file)
|
||||||
|
has_stdin=f
|
||||||
|
is_url=f
|
||||||
|
;;
|
||||||
|
-u | --u | --url)
|
||||||
|
check_dependency curl
|
||||||
|
has_stdin=f
|
||||||
|
is_url=t
|
||||||
|
;;
|
||||||
|
-t | --t | --type)
|
||||||
|
file_type="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
error "Unknown option flag: $1"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ "$is_url" == "t" ]; then
|
||||||
|
encoded_image=$(curl -fs "$1" | b64_encode) || {
|
||||||
|
error "Could not retrieve image from URL $1, error_code: $?"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
elif [ -r "$1" ]; then
|
||||||
|
encoded_image=$(cat "$1" | b64_encode)
|
||||||
|
else
|
||||||
|
error "imgcat: $1: No such file or directory"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
has_stdin=f
|
||||||
|
print_image "$1" 1 "$encoded_image" "$print_filename" "$width" "$height" "$preserve_aspect_ratio" "$file_type"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Read and print stdin
|
||||||
|
if [ $has_stdin = t ]; then
|
||||||
|
print_image "" 1 "$(cat | b64_encode)" 0 "$width" "$height" "$preserve_aspect_ratio" "$file_type"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$has_image_displayed" != "t" ]; then
|
||||||
|
error "No image provided. Check command line options."
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
|
||||||
|
getChanged() {
|
||||||
|
local file="$1"
|
||||||
|
date -r "${file}" "+%s"
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreated() {
|
||||||
|
local d=$(basename $1 | grep -oe "^[0-9]\{12\}")
|
||||||
|
date -j -f "%Y-%m-%d %H:%M" "${d:0:4}-${d:4:2}-${d:6:2} ${d:8:2}:${d:10:2}" '+%s'
|
||||||
|
#date -j -f "%Y-%m-%d" "$(getDocumentMetadataValue "$1" 'created')" "+%s"
|
||||||
|
}
|
||||||
|
|
||||||
|
m2j --content $1 > /tmp/md.json
|
||||||
|
cat /tmp/md.json | jq '.[] + {"body": .content} | .body = .content | del(.content, .basename, .preview)' > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
jq --arg changed "$(getChanged $1)" '. += {"changed": $changed}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
jq --arg image "https://www.maketecheasier.com/assets/uploads/2020/09/markdown-cheatsheet-800x400.jpg.webp" '. += {"image": $image}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
jq --arg type "md" '. += {"type": $type}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
jq --arg created "$(getCreated $1)" '. | .created = $created' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
# jq --arg id "$(echo -n "$(basename $1|xxd -p -u)"| sed "s/[.]/_/g")" '. += {"id": $id}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
jq --arg id "$(echo -n "$(basename $1)"| sed "s/[.]/_/g")" '. += {"id": $id}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
jq --arg title "$(basename $1)" '. += {"title": $title}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
jq --arg refcount "$2" '. += {"refcount": $refcount}' < /tmp/md.json > /tmp/md2.json
|
||||||
|
mv /tmp/md2.json /tmp/md.json
|
||||||
|
|
||||||
|
jq '. | [.]' < /tmp/md.json
|
||||||
|
|
Binary file not shown.
@ -0,0 +1,156 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
|
||||||
|
getDocumentMetadataHeader() {
|
||||||
|
local file="$1"
|
||||||
|
sed -e '/^[@]document[.]meta/,/^[@]end$/!d' "$file" | \
|
||||||
|
grep -ve "^[@]\(document[.]meta\|end\)" | \
|
||||||
|
grep -oe "\S.*$"
|
||||||
|
}
|
||||||
|
|
||||||
|
getDocumentMetadataValue() {
|
||||||
|
local file="$1"
|
||||||
|
local key="$2"
|
||||||
|
|
||||||
|
#Example header:
|
||||||
|
#
|
||||||
|
|
||||||
|
getDocumentMetadataHeader "$file" | ggrep -oP "(?<=${key}: ).*"
|
||||||
|
}
|
||||||
|
|
||||||
|
splitValuesByComma() {
|
||||||
|
local str="$1"
|
||||||
|
|
||||||
|
# Change comma (,) to whitespace and add under braces
|
||||||
|
local array=($(echo "${str}" | tr ',' ' '))
|
||||||
|
|
||||||
|
for value in "${array[@]}"; do
|
||||||
|
echo "$value"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetFilename() {
|
||||||
|
local file="$1"
|
||||||
|
getDocumentMetadataValue "$1" 'title'
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetTags() {
|
||||||
|
local file="$1"
|
||||||
|
# getDocumentMetadataValue "$1" 'categories'| tr ',' ' '
|
||||||
|
local value="$(getDocumentMetadataValue "$1" 'categories'| tr ',' ' ')"
|
||||||
|
splitValuesByComma "${value}"
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetAuthors() {
|
||||||
|
local file="$1"
|
||||||
|
# getDocumentMetadataValue "$1" 'authors'| tr ',' ' '
|
||||||
|
local value="$(getDocumentMetadataValue "$1" 'authors')"
|
||||||
|
splitValuesByComma "${value}"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetDescription() {
|
||||||
|
local file="$1"
|
||||||
|
getDocumentMetadataValue "$1" 'description'
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetCreated() {
|
||||||
|
local file="$1"
|
||||||
|
#date --date="$(getDocumentMetadataValue "$1" 'created')" +"%s"
|
||||||
|
date -j -f "%Y-%m-%d" "$(getDocumentMetadataValue "$1" 'created')" "+%s"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetChanged() {
|
||||||
|
local file="$1"
|
||||||
|
date -r "${file}" "+%s"
|
||||||
|
}
|
||||||
|
|
||||||
|
NorgGetVersion() {
|
||||||
|
local file="$1"
|
||||||
|
getDocumentMetadataValue "$1" 'version'
|
||||||
|
}
|
||||||
|
#description:
|
||||||
|
#authors: nige
|
||||||
|
#categories: bash, ssh, script
|
||||||
|
#created: 2021-12-29
|
||||||
|
#version: 0.0.9
|
||||||
|
|
||||||
|
NorgGetDocumentBody() {
|
||||||
|
local file="$1"
|
||||||
|
local lines=$(( $(getDocumentMetadataHeader "$file" | wc -l) + 3 ))
|
||||||
|
tail -n +$lines "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
#title: 202112291700-sshconnect_script.md
|
||||||
|
#description:
|
||||||
|
#authors: nige
|
||||||
|
#categories: bash, ssh, script
|
||||||
|
#created: 2021-12-29
|
||||||
|
#version: 0.0.9
|
||||||
|
|
||||||
|
#echo "TEST:"
|
||||||
|
#echo
|
||||||
|
#echo "Header:"
|
||||||
|
#echo " Filename: $(NorgGetFilename $1)"
|
||||||
|
#echo " Description: $(NorgGetDescription $1)"
|
||||||
|
#echo " Author: $(NorgGetAuthors $1)"
|
||||||
|
#echo " Tags: $(NorgGetTags $1)"
|
||||||
|
#echo " Create: $(NorgGetCreated $1)"
|
||||||
|
#echo " Changed: $(NorgGetChanged $1)"
|
||||||
|
#echo " Version: $(NorgGetVersion $1)"
|
||||||
|
#echo "Body: $(NorgGetDocumentBody $1)"
|
||||||
|
|
||||||
|
|
||||||
|
# filenameID="$(basename "$1" | xxd -p -u")"
|
||||||
|
filenameID="$(NorgGetFilename "$1" | sed "s/[^0-9a-zA-Z_-]/_/g")"
|
||||||
|
filename="$(basename "$1")"
|
||||||
|
|
||||||
|
type="${filename##*.}"
|
||||||
|
|
||||||
|
case ${type^^} in
|
||||||
|
"SH" ) filetype="bash";;
|
||||||
|
"MD" | "MARKDOWN" ) filetype="markdown";;
|
||||||
|
"norg" ) filetype="neorg";;
|
||||||
|
* ) filetype="${type,,}";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
jq -n \
|
||||||
|
--arg id "${filenameID}" \
|
||||||
|
--arg filename "${filename}" \
|
||||||
|
--arg filetype "${filetype,,}" \
|
||||||
|
--arg description "$(NorgGetDescription "$1" )" \
|
||||||
|
--arg created "$(NorgGetCreated "$1")" \
|
||||||
|
--arg changed "$(NorgGetChanged "$1")" \
|
||||||
|
--arg version "$(NorgGetVersion "$1")" \
|
||||||
|
--arg authors "$(NorgGetAuthors "$1")" \
|
||||||
|
--arg tags "$(NorgGetTags "$1")" \
|
||||||
|
--arg headerlines "$(( $(getDocumentMetadataHeader "$1" | wc -l) + 2 ))" \
|
||||||
|
--arg refcount "$2" \
|
||||||
|
--arg body "$(NorgGetDocumentBody "$1")" \
|
||||||
|
'{ "id": $id,
|
||||||
|
"image": "https://raw.githubusercontent.com/nvim-neorg/neorg/main/res/neorg.svg",
|
||||||
|
"title": $filename,
|
||||||
|
"type": $filetype,
|
||||||
|
"description": $description,
|
||||||
|
"created": $created,
|
||||||
|
"changed": $changed,
|
||||||
|
"version": $version,
|
||||||
|
"authors": [],
|
||||||
|
"tags": [],
|
||||||
|
"headerlines": $headerlines,
|
||||||
|
"refcount": $refcount,
|
||||||
|
"body": $body }' > /tmp/tmpFile
|
||||||
|
while read -re value; do
|
||||||
|
jq --arg value "${value}" '.authors += [ $value ]' /tmp/tmpFile > /tmp/tmpFile2
|
||||||
|
mv /tmp/tmpFile2 /tmp/tmpFile
|
||||||
|
done <<< $(NorgGetAuthors $1)
|
||||||
|
|
||||||
|
while read -e value; do
|
||||||
|
jq --arg value "${value}" '.tags += [ $value ]' /tmp/tmpFile > /tmp/tmpFile2
|
||||||
|
mv /tmp/tmpFile2 /tmp/tmpFile
|
||||||
|
done <<< $(NorgGetTags $1)
|
||||||
|
jq --argjson var "$(< /tmp/tmpFile)" '. |= . + [$var]' <<< "[]"
|
||||||
|
|
||||||
|
|
||||||
|
#jq < /tmp/tmpFile
|
||||||
|
rm /tmp/tmpFile /tmp/tmpFile2 &>/dev/null
|
@ -0,0 +1,20 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
|
||||||
|
ROOT_FOLDER="$HOME/Documents"
|
||||||
|
|
||||||
|
#===# Functions #===#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
readMeta() {
|
||||||
|
|
||||||
|
ls
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i in $(find $ROOT_FOLDER -type f -name ".notemeta"); do
|
||||||
|
true
|
||||||
|
#TODO do Something
|
||||||
|
done
|
@ -0,0 +1,55 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
|
||||||
|
# Author: Nils Gerstner
|
||||||
|
# Last revision: 26st Januray 2019
|
||||||
|
# Version: v1.5
|
||||||
|
# Description: ssh into server from array
|
||||||
|
|
||||||
|
|
||||||
|
# The following variables should be put inside a file, and sourced:
|
||||||
|
source ~/.lib/variables.sh
|
||||||
|
|
||||||
|
pad=" ................................................."
|
||||||
|
#pad=" -------------------------------------------------"
|
||||||
|
if [ -z "${1}" ]; then
|
||||||
|
printf "$grey\e[7m%s$nc\n" "S E R V E R L I S T :"
|
||||||
|
for key in "${!sshserver[@]}"; do
|
||||||
|
printf "$grey%2d) " "$(( ${key}+1 ))"
|
||||||
|
printf "${sshcolor[$key]}%s$grey%s${sshcolor[$key]}%s\n$nc" "${sshserver[$key]}" "${pad:0:$((75-${#sshserver[$key]}-${#sshcomment[$key]}))}" " ${sshcomment[$key]}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# echo
|
||||||
|
# if [ -z $1 ]; then
|
||||||
|
# echo "Please choose a server to connect to"
|
||||||
|
# read pc
|
||||||
|
# #echo
|
||||||
|
# else
|
||||||
|
# pc="${1}"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
re='^[0-9]+$'
|
||||||
|
|
||||||
|
if [ -z $1 ]; then
|
||||||
|
echo "Please choose a server to connect to"
|
||||||
|
read pc
|
||||||
|
#echo
|
||||||
|
else
|
||||||
|
pc="${1}"
|
||||||
|
fi
|
||||||
|
[[ $pc -eq $pc ]] && echo true || echo false
|
||||||
|
#while ! [[ $pc =~ '^[0-9]+$' ]]; do
|
||||||
|
while [[ $pc -ne $pc && $pc -gt $(($key+1)) && $ps -lt 0 ]]; do
|
||||||
|
>&2 echo "error: '${pc}' is not a number between 1 and $(($key+1))";
|
||||||
|
echo "Please choose a server to connect to"
|
||||||
|
read pc
|
||||||
|
done
|
||||||
|
|
||||||
|
# Login to server. If login fails, ssh-copy-id to server and try again.
|
||||||
|
printf "${sshcolor[$(( pc-1 ))]}%s$bold%s\n$nc" "Connecting to " "${sshserver[$(( $pc-1 ))]}"
|
||||||
|
ssh -o PasswordAuthentication=no -o ConnectTimeout=7 ${sshserver[$(( $pc-1 ))]}
|
||||||
|
#ssh -o PasswordAuthentication=no -o ConnectTimeout=7 ${sshserver[$(( $pc-1 ))]} || \
|
||||||
|
# (>&2 printf "No Password set\n\n"; \
|
||||||
|
# ssh-copy-id -o ConnectTimeout=7 ${sshserver[$(( $pc-1 ))]} 2>/dev/null; \
|
||||||
|
# ssh -o ConnectTimeout=7 ${sshserver[$(( $pc-1 ))]})
|
||||||
|
unset sshserver; unset sshcomment & printf "$nc"
|
||||||
|
printf "$nc"
|
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
test01="ett"
|
||||||
|
echo $test01
|
||||||
|
test01="två"
|
||||||
|
echo $test01
|
||||||
|
|
@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
all=$1
|
||||||
|
notes=/Users/nige/notes/
|
||||||
|
marker=/Users/nige/lua/.marker
|
||||||
|
|
||||||
|
[ -f $marker ] || touch $marker
|
||||||
|
|
||||||
|
echo "Marker time: $(date -r "${marker}")"
|
||||||
|
|
||||||
|
now=$(date '+%Y%m%d%H%M.%S')
|
||||||
|
|
||||||
|
updateNote() {
|
||||||
|
local i=$1
|
||||||
|
echo
|
||||||
|
echo "Current filename: $i"
|
||||||
|
#count=$(grep -e "[\({]\(./\)*$(basename $i)\(/*#[^)}]*\)*[\)}]" ${notes}*| wc -l )
|
||||||
|
count=$(grep -e "$1" ${notes}*| wc -l )
|
||||||
|
echo "References: $count"
|
||||||
|
if [[ "${i}" == *.norg ]]; then
|
||||||
|
echo
|
||||||
|
echo "Current filetype: NEORG"
|
||||||
|
/Users/nige/bin/norg-functions.sh "$i" $count > /tmp/update.json
|
||||||
|
elif [[ "${i}" == *.md ]]; then
|
||||||
|
echo
|
||||||
|
echo "Current filetype: MARKDOWN"
|
||||||
|
/Users/nige/bin/md-functions.sh "$i" $count > /tmp/update.json
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "Unsupported filetype..."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /tmp/update.json ]; then
|
||||||
|
update=true
|
||||||
|
curl -X POST 'http://127.0.0.1:7700/indexes/notes/documents?primaryKey=id' -H 'Content-Type: application/json' --data-binary @/tmp/update.json
|
||||||
|
mv /tmp/update.json "/tmp/${i//\//\\}.json"
|
||||||
|
#rm /tmp/update.json
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
echo "Start Update"
|
||||||
|
update=false
|
||||||
|
for i in $( [ "$all" == "all" ] && find ~/notes/ -type f || find ~/notes/ -type f -newer "$marker"); do
|
||||||
|
time updateNote $i
|
||||||
|
echo "-----------------------"
|
||||||
|
done
|
||||||
|
if [ "$update" == "true" ]; then
|
||||||
|
echo
|
||||||
|
touch -t $now $marker
|
||||||
|
fi
|
||||||
|
echo "Update DONE"
|
||||||
|
echo "Current Marker time: $(date -r "${marker}")"
|
||||||
|
}
|
||||||
|
time update
|
@ -0,0 +1,7 @@
|
|||||||
|
#!/opt/homebrew/bin/bash
|
||||||
|
#Example for bash split string without $IFS
|
||||||
|
|
||||||
|
xpath="$(echo "$2"| sed -e "s/\/\([^/]\+\)/\/*[local-name()='\1']/g" | sed -e "s/^\([^\/]\+\)/\/\/*[local-name() = '\1']/")"
|
||||||
|
xmllint --xpath "${xpath}" $1
|
||||||
|
#echo
|
||||||
|
echo "xpath= ${xpath}"
|
Loading…
Reference in new issue