commit 004cf44189ee1cbe0413008111f00e8473df6765 Author: Nils Gerstner Date: Mon Mar 27 16:16:28 2023 +0200 Initial commit diff --git a/.bashrc b/.bashrc new file mode 100755 index 0000000..033d14a --- /dev/null +++ b/.bashrc @@ -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] [more days] + if [ "$1" = "" ]; then + echo "args [-q] [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" diff --git a/.config/git_custom_configuration/git_gerstner_config b/.config/git_custom_configuration/git_gerstner_config new file mode 100644 index 0000000..7a1dc93 --- /dev/null +++ b/.config/git_custom_configuration/git_gerstner_config @@ -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 diff --git a/.config/git_custom_configuration/git_replyto_config b/.config/git_custom_configuration/git_replyto_config new file mode 100644 index 0000000..fcfa5c6 --- /dev/null +++ b/.config/git_custom_configuration/git_replyto_config @@ -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 diff --git a/.config/git_custom_configuration/git_vcc_config b/.config/git_custom_configuration/git_vcc_config new file mode 100644 index 0000000..60ccafe --- /dev/null +++ b/.config/git_custom_configuration/git_vcc_config @@ -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 diff --git a/.config/nvim/.mind/state.json b/.config/nvim/.mind/state.json new file mode 100644 index 0000000..ffed9f7 --- /dev/null +++ b/.config/nvim/.mind/state.json @@ -0,0 +1 @@ +{"contents":[{"text":"nvim"}],"icon":" ","uid":"20230115195355","type":1} \ No newline at end of file diff --git a/.config/nvim/ftplugin/java.lua_ b/.config/nvim/ftplugin/java.lua_ new file mode 100644 index 0000000..f695ee6 --- /dev/null +++ b/.config/nvim/ftplugin/java.lua_ @@ -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) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..25adfd4 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,2 @@ +require("setup") +require("note-workflow") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..7ad2124 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -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" } +} \ No newline at end of file diff --git a/.config/nvim/lua/.luarc.json b/.config/nvim/lua/.luarc.json new file mode 100644 index 0000000..56f5da9 --- /dev/null +++ b/.config/nvim/lua/.luarc.json @@ -0,0 +1,7 @@ +{ + "diagnostics.disable": [ + "undefined-global", + "unused-local", + "unused-function" + ] +} \ No newline at end of file diff --git a/.config/nvim/lua/json.lua b/.config/nvim/lua/json.lua new file mode 100644 index 0000000..50610de --- /dev/null +++ b/.config/nvim/lua/json.lua @@ -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 diff --git a/.config/nvim/lua/note-workflow/autocmd.lua b/.config/nvim/lua/note-workflow/autocmd.lua new file mode 100644 index 0000000..bae6fcb --- /dev/null +++ b/.config/nvim/lua/note-workflow/autocmd.lua @@ -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", + } +) diff --git a/.config/nvim/lua/note-workflow/delete.lua b/.config/nvim/lua/note-workflow/delete.lua new file mode 100644 index 0000000..3e44b15 --- /dev/null +++ b/.config/nvim/lua/note-workflow/delete.lua @@ -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 diff --git a/.config/nvim/lua/note-workflow/init.lua b/.config/nvim/lua/note-workflow/init.lua new file mode 100644 index 0000000..a456713 --- /dev/null +++ b/.config/nvim/lua/note-workflow/init.lua @@ -0,0 +1,2 @@ +require("note-workflow.autocmd") +require("note-workflow.keymap") diff --git a/.config/nvim/lua/note-workflow/keymap.lua b/.config/nvim/lua/note-workflow/keymap.lua new file mode 100644 index 0000000..d03e586 --- /dev/null +++ b/.config/nvim/lua/note-workflow/keymap.lua @@ -0,0 +1,7 @@ +local note_workflow = require('note-workflow.notes') +vim.keymap.set("n", "ms", note_workflow.search, { desc = "Search Notes via Meilisearch" }) + +vim.keymap.set("n", "ma", note_workflow.updateAll, { desc = "Update notes" }) +vim.keymap.set("n", "nz", note_workflow.newNeorgNote, { desc = "Create a new Neorg note" }) +vim.keymap.set("n", "nm", note_workflow.newMarkdownNote, { desc = "Create a new Markdown note" }) +vim.keymap.set("n", "nw", note_workflow.createWorknote, { desc = "Create an inline worknote" }) diff --git a/.config/nvim/lua/note-workflow/notes.lua b/.config/nvim/lua/note-workflow/notes.lua new file mode 100644 index 0000000..e4f01f6 --- /dev/null +++ b/.config/nvim/lua/note-workflow/notes.lua @@ -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 diff --git a/.config/nvim/lua/setup/autocmd.lua b/.config/nvim/lua/setup/autocmd.lua new file mode 100644 index 0000000..5a01016 --- /dev/null +++ b/.config/nvim/lua/setup/autocmd.lua @@ -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", +}) diff --git a/.config/nvim/lua/setup/camel.lua b/.config/nvim/lua/setup/camel.lua new file mode 100644 index 0000000..33dda7a --- /dev/null +++ b/.config/nvim/lua/setup/camel.lua @@ -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 {} diff --git a/.config/nvim/lua/setup/cmp.lua b/.config/nvim/lua/setup/cmp.lua new file mode 100644 index 0000000..201078e --- /dev/null +++ b/.config/nvim/lua/setup/cmp.lua @@ -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({ + [''] = cmp.mapping.select_prev_item(select_opts), + [''] = cmp.mapping.select_next_item(select_opts), + [''] = cmp.mapping.select_next_item(select_opts), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { 'i', 's' }), + [''] = 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' } }) +}) diff --git a/.config/nvim/lua/setup/dap.lua b/.config/nvim/lua/setup/dap.lua new file mode 100644 index 0000000..a376cc0 --- /dev/null +++ b/.config/nvim/lua/setup/dap.lua @@ -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 = '⏹' + } + } +}) diff --git a/.config/nvim/lua/setup/dap.md b/.config/nvim/lua/setup/dap.md new file mode 100644 index 0000000..a391634 --- /dev/null +++ b/.config/nvim/lua/setup/dap.md @@ -0,0 +1,25 @@ +# DAP Normal commands + + +- [DAP Normal commands](#dap-normal-commands) + + + +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 +``` diff --git a/.config/nvim/lua/setup/init.lua b/.config/nvim/lua/setup/init.lua new file mode 100644 index 0000000..1edfb46 --- /dev/null +++ b/.config/nvim/lua/setup/init.lua @@ -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") diff --git a/.config/nvim/lua/setup/jdtls-setup.lua b/.config/nvim/lua/setup/jdtls-setup.lua new file mode 100644 index 0000000..6d3ba5c --- /dev/null +++ b/.config/nvim/lua/setup/jdtls-setup.lua @@ -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 + } + } +} diff --git a/.config/nvim/lua/setup/lsp.lua b/.config/nvim/lua/setup/lsp.lua new file mode 100644 index 0000000..2db4708 --- /dev/null +++ b/.config/nvim/lua/setup/lsp.lua @@ -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", "vws", vim.lsp.buf.workspace_symbol, addDesc(opts, "Query workspace")) + vim.keymap.set("n", "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", "vca", vim.lsp.buf.code_action, addDesc(opts, "Code action")) + -- vim.keymap.set("n", "", vim.lsp.buf.code_action, + vim.keymap.set("n", "", ":CodeActionMenu", addDesc(opts, "Code action")) + vim.keymap.set("n", "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", "vrn", vim.lsp.buf.rename, addDesc(opts, "Rename")) + vim.keymap.set("n", "", vim.lsp.buf.rename, addDesc(opts, "Rename")) + vim.keymap.set("i", "", 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{} diff --git a/.config/nvim/lua/setup/plugins.lua b/.config/nvim/lua/setup/plugins.lua new file mode 100644 index 0000000..47e077f --- /dev/null +++ b/.config/nvim/lua/setup/plugins.lua @@ -0,0 +1,403 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +local plugins = { + { "preservim/vim-markdown", dependencies = "godlygeek/tabular" }, + { "nathanielc/vim-tickscript" }, + { "jghauser/follow-md-links.nvim" }, + { + "toppair/peek.nvim", + build = "deno task --quiet build:fast", + config = function() + require("peek").setup() + local peek = require("peek") + + vim.api.nvim_create_user_command("PeekOpen", function() + if not peek.is_open() and vim.bo[vim.api.nvim_get_current_buf()].filetype == "markdown" then + -- vim.fn.system("i3-msg split horizontal") + peek.open() + end + end, {}) + + vim.api.nvim_create_user_command("PeekClose", function() + if peek.is_open() then + peek.close() + -- vim.fn.system("i3-msg move left") + end + end, {}) + end, + }, + + { + "nvim-telescope/telescope.nvim", + tag = "0.1.0", + dependencies = "nvim-lua/plenary.nvim", + }, + + { + "jackMort/ChatGPT.nvim", + config = function() + require("chatgpt").setup({ + -- optional configuration + }) + end, + dependencies = { + "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + }, + }, + + { + "rose-pine/neovim", + name = "rose-pine", + lazy = false, + priority = 1000, + config = function() + require("rose-pine").setup() + vim.cmd("colorscheme rose-pine") + end, + }, + + { "TimUntersberger/neogit", dependencies = "nvim-lua/plenary.nvim" }, + + -- { "tpope/vim-fugitive" }, + + { + "nvim-lualine/lualine.nvim", + config = function() + require("lualine").setup({ + options = { theme = "auto" }, + tabline = { + lualine_a = {}, + lualine_b = { "branch" }, + -- lualine_c = { 'filename' }, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + }, + sections = { + lualine_b = { + "branch", + "diff", + { + "diagnostics", + sections = { "error", "warn", "info", "hint" }, + diagnostics_color = { + -- Same values as the general color option can be used here. + error = "DiagnosticError", -- Changes diagnostics' error color. + warn = "DiagnosticWarn", -- Changes diagnostics' warn color. + info = "DiagnosticInfo", -- Changes diagnostics' info color. + hint = "DiagnosticHint", -- Changes diagnostics' hint color. + }, + symbols = { error = "E", warn = "W", info = "I", hint = "H" }, + colored = true, -- Displays diagnostics status in color if set to true. + update_in_insert = false, -- Update diagnostics in insert mode. + always_visible = false, -- Show diagnostics even if there are none. + }, + }, + -- lualine_c = { sections = { 'lsp_progress' } }, + lualine_x = { + "encoding", + { + "fileformat", + symbols = { + unix = "unix", -- e712 + dos = "dos", -- e70f + mac = "mac", -- e711 + }, + }, + "filetype", + "lsp_progress", + -- "tabnine", + }, + }, + }) + end, + }, + + { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "lua", "vim", "help", "query" }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + -- List of parsers to ignore installing (for "all") + ignore_install = { "javascript" }, + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + enable = true, + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + disable = { "c", "rust" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + }) + end, + }, + { "nvim-treesitter/playground" }, + { "theprimeagen/harpoon" }, + { "mbbill/undotree" }, + + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + + { + "williamboman/mason-lspconfig.nvim", + dependencies = { "neovim/nvim-lspconfig" }, + }, + + { + "jay-babu/mason-null-ls.nvim", + -- config = function() + -- 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 + -- }) + -- + -- local null_ls = require("null-ls") + -- null_ls.setup( + -- -- { + -- -- sources = { + -- -- null_ls.builtins.formatting.beautysh, + -- -- }, + -- -- } + -- ) + -- mason_null_ls.setup_handlers() + -- end, + dependencies = { "jose-elias-alvarez/null-ls.nvim" }, + }, + + -- Snippets + { "L3MON4D3/LuaSnip" }, + { "rafamadriz/friendly-snippets" }, + + -- Autocompletion + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-cmdline" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lua" }, + { "hrsh7th/cmp-path" }, + { "hrsh7th/nvim-cmp" }, + { "saadparwaiz1/cmp_luasnip" }, + + -- -- Debugging + { "mfussenegger/nvim-jdtls" }, + { "mfussenegger/nvim-dap" }, + { "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap" } }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + dependencies = { + { "numToStr/Comment.nvim" }, + { "nvim-treesitter/nvim-treesitter" }, + }, + config = function() + require("nvim-treesitter.configs").setup({ + context_commentstring = { enable = true, enable_autocmd = false }, + }) + end, + }, + + { + "numToStr/Comment.nvim", + config = function() + require("Comment").setup({ + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), + }) + end, + }, + + { + "folke/which-key.nvim", + config = function() + require("which-key").setup({}) + end, + }, + + -- { + -- "tzachar/cmp-tabnine", + -- build = "./install.sh", + -- dependencies = "hrsh7th/nvim-cmp", + -- config = function() + -- require("cmp_tabnine").setup({ + -- max_lines = 1000, + -- max_num_results = 20, + -- sort = true, + -- run_on_every_keystroke = true, + -- snippet_placeholder = "..", + -- ignored_file_types = { + -- -- default is not to ignore + -- -- uncomment to ignore in lua: + -- -- lua = true + -- norg = true, + -- }, + -- show_prediction_strength = true, + -- }) + -- end, + -- }, + + { "weilbith/nvim-code-action-menu", cmd = "CodeActionMenu" }, + { + "kosayoda/nvim-lightbulb", + dependencies = "antoinemadec/FixCursorHold.nvim", + }, + + { + "nvim-neotest/neotest", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "antoinemadec/FixCursorHold.nvim", + "nvim-neotest/neotest-vim-test", + }, + config = function() + require("neotest").setup({ + adapters = { + require("neotest-vim-test")({ ignore_filetypes = {} }), + }, + }) + end, + }, + + { "nvim-neorg/tree-sitter-norg" }, + { "nvim-neorg/neorg-telescope" }, + { + "nvim-neorg/neorg", + config = function() + require("neorg").setup({ + load = { + ["core.defaults"] = {}, -- Load all the default modules + ["core.norg.concealer"] = { + -- config = { + -- folds = false, + -- }, + }, + ["core.norg.dirman"] = { -- Manage your directories with Neorg + config = { + workspaces = { + work = "/Users/nige/notes/work", + home = "/Users/nige/notes/home", + gtd = "/Users/nige/Documents/PARA/PROJECTS/example_workspaces/gtd", + -- gtd = "/Users/nige/gtd" + }, + }, + }, + -- ["core.gtd.base"] = { + -- config = { + -- workspace = "gtd", + -- -- workspace = "notes", + -- }, + -- }, + ["core.norg.completion"] = { + config = { + engine = "nvim-cmp", -- We current support nvim-compe and nvim-cmp only + }, + }, + ["core.norg.qol.todo_items"] = {}, + -- ["core.norg.qol.toc"] = { + -- config = { -- Note that this table is optional and doesn't need to be provided + -- -- Configuration here + -- default_toc_mode = "toqflist" + -- } + -- }, + -- ["core.norg.journal"] = { + -- config = { -- Note that this table is optional and doesn't need to be provided + -- -- workspace = "notes", + -- } + -- }, + -- ["core.presenter"] = { + -- config = { -- Note that this table is optional and doesn't need to be provided + -- -- Configuration here + -- -- zen_mode = "truezen", + -- zen_mode = "zen-mode" + -- } + -- }, + ["core.export"] = { + config = { -- Note that this table is optional and doesn't need to be provided + -- Configuration here + }, + }, + ["core.integrations.telescope"] = {}, -- Enable the telescope module + }, + }) + end, + dependencies = "nvim-neorg/neorg-telescope", -- Be sure to pull in the repo + }, +} + +local opts = { + ui = { + -- a number <1 is a percentage., >1 is a fixed size + size = { width = 0.8, height = 0.8 }, + wrap = true, -- wrap the lines in the ui + -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. + border = "none", + icons = { + cmd = "cmd", + config = "config", + event = "event", + ft = "ft", + init = "init", + import = "import", + keys = "⚿", + lazy = "lazy", + loaded = "●", + not_loaded = "○", + plugin = "+", + runtime = "runtime", + source = "⦻", + start = "⏵", + task = "✔ ", + list = { + "●", + "➜", + "★", + "‒", + }, + }, + }, +} + +require("lazy").setup(plugins, opts) diff --git a/.config/nvim/lua/setup/remap.lua b/.config/nvim/lua/setup/remap.lua new file mode 100644 index 0000000..4f3b3f1 --- /dev/null +++ b/.config/nvim/lua/setup/remap.lua @@ -0,0 +1,35 @@ +vim.g.mapleader = " " + +vim.keymap.set("i", "jj", "", { desc = "Exit insert mode" }) +vim.keymap.set("t", "jj", "", { desc = "Exit terminal input mode" }) +vim.keymap.set("v", "<", "", ">gv", { desc = "Indent and mark again" }) + +vim.keymap.set("v", "J", ":m '>+1gv=gv", { desc = "Move markt row(s) down" }) +vim.keymap.set("v", "K", ":m '<-2gv=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", "", "zz", { desc = "Page down and center" }) +vim.keymap.set("n", "", "zz", { desc = "Page up and center" }) + +vim.keymap.set({ "n", "v" }, "y", [["+y]], { desc = "Yank into system clipboard" }) +vim.keymap.set("n", "yy", [["+yy]], { desc = "Yank line into system clipboard" }) +vim.keymap.set("n", "p", [["+p]], { desc = "Put text from system clipboard after cursor" }) +vim.keymap.set("n", "P", [["+P]], { desc = "Put text from system clipboard before cursor" }) + +vim.keymap.set({ "n", "v" }, "d", [["_d]], { desc = "Delete without saving to register" }) + +vim.keymap.set("n", "Q", "", { desc = "" }) +-- vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer", { desc = "" }) +vim.keymap.set("n", "f", vim.lsp.buf.format, { desc = "Format current buffer" }) + +vim.keymap.set("n", "", "cnextzz", { desc = "Center on next quickfix item" }) +vim.keymap.set("n", "", "cprevzz", { desc = "Center on previous quickfix item" }) +vim.keymap.set("n", "k", "lnextzz", { desc = "Center on next locationlist item" }) +vim.keymap.set("n", "j", "lprevzz", { desc = "Center on previous locationlist item" }) + +vim.keymap.set("n", "x", "!chmod +x %", { silent = true, desc = "Make current file executable" }) + +vim.keymap.set("t", "", "", { desc = "Exit terminal input mode" }) +vim.keymap.set("t", "", "", { desc = "Exit mode" }) +vim.keymap.set("t", "", "", { desc = "Exit mode" }) diff --git a/.config/nvim/lua/setup/set.lua b/.config/nvim/lua/setup/set.lua new file mode 100644 index 0000000..0e47398 --- /dev/null +++ b/.config/nvim/lua/setup/set.lua @@ -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 diff --git a/.config/nvim/lua/setup/test.lua b/.config/nvim/lua/setup/test.lua new file mode 100644 index 0000000..fa1abb9 --- /dev/null +++ b/.config/nvim/lua/setup/test.lua @@ -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') + + diff --git a/.config/nvim/lua/setup/utils.lua b/.config/nvim/lua/setup/utils.lua new file mode 100644 index 0000000..7031603 --- /dev/null +++ b/.config/nvim/lua/setup/utils.lua @@ -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 diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..44cdb20 --- /dev/null +++ b/.gitconfig @@ -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 diff --git a/.tmux.conf b/.tmux.conf new file mode 100755 index 0000000..ba5e966 --- /dev/null +++ b/.tmux.conf @@ -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' diff --git a/bin/_lua-language-server b/bin/_lua-language-server new file mode 100755 index 0000000..e0c2a76 --- /dev/null +++ b/bin/_lua-language-server @@ -0,0 +1,4 @@ +#!/bin/bash +exec "~/lua/lua-language-server/bin/lua-language-server" "$@" + +~/lua/lua-language-server diff --git a/bin/chezmoi b/bin/chezmoi new file mode 100755 index 0000000..6da5d6c Binary files /dev/null and b/bin/chezmoi differ diff --git a/bin/convertNeorgToMd.sh b/bin/convertNeorgToMd.sh new file mode 100755 index 0000000..f69f604 --- /dev/null +++ b/bin/convertNeorgToMd.sh @@ -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 diff --git a/bin/convertNorg.sh b/bin/convertNorg.sh new file mode 100755 index 0000000..f7ec4f9 --- /dev/null +++ b/bin/convertNorg.sh @@ -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}" $@ diff --git a/bin/createNewIndex.sh b/bin/createNewIndex.sh new file mode 100755 index 0000000..baa797b --- /dev/null +++ b/bin/createNewIndex.sh @@ -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 diff --git a/bin/fastfont.sh b/bin/fastfont.sh new file mode 100755 index 0000000..98f4f0f --- /dev/null +++ b/bin/fastfont.sh @@ -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 diff --git a/bin/fontcharlist.sh b/bin/fontcharlist.sh new file mode 100755 index 0000000..f640b5d --- /dev/null +++ b/bin/fontcharlist.sh @@ -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"'}' diff --git a/bin/github-auth.sh b/bin/github-auth.sh new file mode 100755 index 0000000..50d56c8 --- /dev/null +++ b/bin/github-auth.sh @@ -0,0 +1,2 @@ +echo "username=nils-gg" +echo 'password=tcT7-9n2`@\HKQ$n{N{_Y+oPVLS-=K@w$)D*B$MERkDk4yW4%E' diff --git a/bin/imgcat b/bin/imgcat new file mode 100755 index 0000000..39dd229 --- /dev/null +++ b/bin/imgcat @@ -0,0 +1,241 @@ +#!/usr/bin/env bash + +set -o pipefail + +# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux; +# ST, and for all ESCs in 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 diff --git a/bin/l.json b/bin/l.json new file mode 100644 index 0000000..b3ee279 --- /dev/null +++ b/bin/l.json @@ -0,0 +1,1886 @@ +[ + { + "status": "processed", + "updateId": 1478, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.123, + "enqueuedAt": "2022-02-01T14:51:25.978003900Z", + "processedAt": "2022-02-01T14:51:26.102621200Z" + }, + { + "status": "processed", + "updateId": 1479, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.161, + "enqueuedAt": "2022-02-01T14:51:26.556063900Z", + "processedAt": "2022-02-01T14:51:26.718160300Z" + }, + { + "status": "processed", + "updateId": 1480, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.141, + "enqueuedAt": "2022-02-01T14:51:27.191689900Z", + "processedAt": "2022-02-01T14:51:27.333914800Z" + }, + { + "status": "processed", + "updateId": 1481, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.151, + "enqueuedAt": "2022-02-01T14:51:27.817438400Z", + "processedAt": "2022-02-01T14:51:27.969862800Z" + }, + { + "status": "processed", + "updateId": 1482, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.111, + "enqueuedAt": "2022-02-01T14:51:28.385582600Z", + "processedAt": "2022-02-01T14:51:28.499100900Z" + }, + { + "status": "processed", + "updateId": 1483, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.151, + "enqueuedAt": "2022-02-01T14:51:29.011952400Z", + "processedAt": "2022-02-01T14:51:29.164656200Z" + }, + { + "status": "processed", + "updateId": 1484, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.142, + "enqueuedAt": "2022-02-01T14:51:29.643648100Z", + "processedAt": "2022-02-01T14:51:29.788425Z" + }, + { + "status": "processed", + "updateId": 1485, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.13, + "enqueuedAt": "2022-02-01T14:51:30.293926100Z", + "processedAt": "2022-02-01T14:51:30.426902800Z" + }, + { + "status": "processed", + "updateId": 1486, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.165, + "enqueuedAt": "2022-02-01T14:51:30.827704Z", + "processedAt": "2022-02-01T14:51:30.993708700Z" + }, + { + "status": "processed", + "updateId": 1487, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.175, + "enqueuedAt": "2022-02-01T14:51:31.369626700Z", + "processedAt": "2022-02-01T14:51:31.546447Z" + }, + { + "status": "processed", + "updateId": 1488, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.183, + "enqueuedAt": "2022-02-01T14:51:31.917297600Z", + "processedAt": "2022-02-01T14:51:32.101676800Z" + }, + { + "status": "processed", + "updateId": 1489, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.178, + "enqueuedAt": "2022-02-01T14:51:32.458332700Z", + "processedAt": "2022-02-01T14:51:32.638151700Z" + }, + { + "status": "processed", + "updateId": 1490, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.136, + "enqueuedAt": "2022-02-01T14:51:32.998192300Z", + "processedAt": "2022-02-01T14:51:33.135313900Z" + }, + { + "status": "processed", + "updateId": 1491, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.192, + "enqueuedAt": "2022-02-01T14:51:33.755440700Z", + "processedAt": "2022-02-01T14:51:33.948940400Z" + }, + { + "status": "processed", + "updateId": 1492, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.164, + "enqueuedAt": "2022-02-01T14:51:34.352511700Z", + "processedAt": "2022-02-01T14:51:34.517729300Z" + }, + { + "status": "processed", + "updateId": 1493, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.125, + "enqueuedAt": "2022-02-01T14:51:34.919199400Z", + "processedAt": "2022-02-01T14:51:35.045788600Z" + }, + { + "status": "processed", + "updateId": 1494, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.147, + "enqueuedAt": "2022-02-01T14:51:35.535079900Z", + "processedAt": "2022-02-01T14:51:35.683670800Z" + }, + { + "status": "processed", + "updateId": 1495, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.135, + "enqueuedAt": "2022-02-01T14:51:36.150295300Z", + "processedAt": "2022-02-01T14:51:36.326175300Z" + }, + { + "status": "processed", + "updateId": 1496, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.144, + "enqueuedAt": "2022-02-01T14:51:36.768098500Z", + "processedAt": "2022-02-01T14:51:36.913246500Z" + }, + { + "status": "processed", + "updateId": 1497, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.182, + "enqueuedAt": "2022-02-01T14:51:37.393272100Z", + "processedAt": "2022-02-01T14:51:37.576534800Z" + }, + { + "status": "processed", + "updateId": 1498, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.184, + "enqueuedAt": "2022-02-01T14:51:38.240129200Z", + "processedAt": "2022-02-01T14:51:38.425808100Z" + }, + { + "status": "processed", + "updateId": 1499, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.204, + "enqueuedAt": "2022-02-01T14:51:38.951959100Z", + "processedAt": "2022-02-01T14:51:39.157592800Z" + }, + { + "status": "processed", + "updateId": 1500, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.18, + "enqueuedAt": "2022-02-01T14:51:39.627362300Z", + "processedAt": "2022-02-01T14:51:39.809101200Z" + }, + { + "status": "processed", + "updateId": 1501, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.181, + "enqueuedAt": "2022-02-01T14:51:40.214441Z", + "processedAt": "2022-02-01T14:51:40.397269700Z" + }, + { + "status": "processed", + "updateId": 1502, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.175, + "enqueuedAt": "2022-02-01T14:51:40.848301300Z", + "processedAt": "2022-02-01T14:51:41.024344800Z" + }, + { + "status": "processed", + "updateId": 1503, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.221, + "enqueuedAt": "2022-02-01T14:51:41.679794200Z", + "processedAt": "2022-02-01T14:51:41.902602400Z" + }, + { + "status": "processed", + "updateId": 1504, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.209, + "enqueuedAt": "2022-02-01T14:51:42.282476500Z", + "processedAt": "2022-02-01T14:51:42.492367800Z" + }, + { + "status": "processed", + "updateId": 1505, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.195, + "enqueuedAt": "2022-02-01T14:51:42.953193300Z", + "processedAt": "2022-02-01T14:51:43.149774700Z" + }, + { + "status": "processed", + "updateId": 1506, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.212, + "enqueuedAt": "2022-02-01T14:51:43.556048300Z", + "processedAt": "2022-02-01T14:51:43.769689800Z" + }, + { + "status": "processed", + "updateId": 1507, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.188, + "enqueuedAt": "2022-02-01T14:51:44.145048100Z", + "processedAt": "2022-02-01T14:51:44.335252700Z" + }, + { + "status": "processed", + "updateId": 1508, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.21, + "enqueuedAt": "2022-02-01T14:51:44.788624300Z", + "processedAt": "2022-02-01T14:51:44.999569100Z" + }, + { + "status": "processed", + "updateId": 1509, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.186, + "enqueuedAt": "2022-02-01T14:51:45.442713500Z", + "processedAt": "2022-02-01T14:51:45.630267800Z" + }, + { + "status": "processed", + "updateId": 1510, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.217, + "enqueuedAt": "2022-02-01T14:51:46.153946Z", + "processedAt": "2022-02-01T14:51:46.390126100Z" + }, + { + "status": "processed", + "updateId": 1511, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.237, + "enqueuedAt": "2022-02-01T14:51:46.984210500Z", + "processedAt": "2022-02-01T14:51:47.222755900Z" + }, + { + "status": "processed", + "updateId": 1512, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.262, + "enqueuedAt": "2022-02-01T14:51:47.614835200Z", + "processedAt": "2022-02-01T14:51:47.878416100Z" + }, + { + "status": "processed", + "updateId": 1513, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.322, + "enqueuedAt": "2022-02-01T14:51:48.560203200Z", + "processedAt": "2022-02-01T14:51:48.884056600Z" + }, + { + "status": "processed", + "updateId": 1514, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.184, + "enqueuedAt": "2022-02-01T14:51:49.720200700Z", + "processedAt": "2022-02-01T14:51:49.906087100Z" + }, + { + "status": "processed", + "updateId": 1515, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.197, + "enqueuedAt": "2022-02-01T14:51:50.481104500Z", + "processedAt": "2022-02-01T14:51:50.679604700Z" + }, + { + "status": "processed", + "updateId": 1516, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.21, + "enqueuedAt": "2022-02-01T14:51:51.246553800Z", + "processedAt": "2022-02-01T14:51:51.459659800Z" + }, + { + "status": "processed", + "updateId": 1517, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.146, + "enqueuedAt": "2022-02-01T14:51:51.897686800Z", + "processedAt": "2022-02-01T14:51:52.044944700Z" + }, + { + "status": "processed", + "updateId": 1518, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.306, + "enqueuedAt": "2022-02-01T14:51:52.548634200Z", + "processedAt": "2022-02-01T14:51:52.856625500Z" + }, + { + "status": "processed", + "updateId": 1519, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.187, + "enqueuedAt": "2022-02-01T14:51:53.715621800Z", + "processedAt": "2022-02-01T14:51:53.904756500Z" + }, + { + "status": "processed", + "updateId": 1520, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.178, + "enqueuedAt": "2022-02-01T14:51:55.899282Z", + "processedAt": "2022-02-01T14:51:56.078725Z" + }, + { + "status": "processed", + "updateId": 1521, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.228, + "enqueuedAt": "2022-02-01T14:51:56.550156200Z", + "processedAt": "2022-02-01T14:51:56.780319700Z" + }, + { + "status": "processed", + "updateId": 1522, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.202, + "enqueuedAt": "2022-02-01T14:51:57.227870200Z", + "processedAt": "2022-02-01T14:51:57.431250700Z" + }, + { + "status": "processed", + "updateId": 1523, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.305, + "enqueuedAt": "2022-02-01T14:51:57.916653700Z", + "processedAt": "2022-02-01T14:51:58.222996900Z" + }, + { + "status": "processed", + "updateId": 1524, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.203, + "enqueuedAt": "2022-02-01T14:51:58.754138300Z", + "processedAt": "2022-02-01T14:51:58.958334700Z" + }, + { + "status": "processed", + "updateId": 1525, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.218, + "enqueuedAt": "2022-02-01T14:51:59.456136500Z", + "processedAt": "2022-02-01T14:51:59.676054500Z" + }, + { + "status": "processed", + "updateId": 1526, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.259, + "enqueuedAt": "2022-02-01T14:52:00.074093700Z", + "processedAt": "2022-02-01T14:52:00.334145500Z" + }, + { + "status": "processed", + "updateId": 1527, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.287, + "enqueuedAt": "2022-02-01T14:52:00.713229600Z", + "processedAt": "2022-02-01T14:52:01.001718800Z" + }, + { + "status": "processed", + "updateId": 1528, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.23, + "enqueuedAt": "2022-02-01T14:52:01.328351400Z", + "processedAt": "2022-02-01T14:52:01.560472200Z" + }, + { + "status": "processed", + "updateId": 1529, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.24, + "enqueuedAt": "2022-02-01T14:52:01.931513400Z", + "processedAt": "2022-02-01T14:52:02.172928300Z" + }, + { + "status": "processed", + "updateId": 1530, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.237, + "enqueuedAt": "2022-02-01T14:52:02.529822Z", + "processedAt": "2022-02-01T14:52:02.768758200Z" + }, + { + "status": "processed", + "updateId": 1531, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.241, + "enqueuedAt": "2022-02-01T14:52:03.145595500Z", + "processedAt": "2022-02-01T14:52:03.388037900Z" + }, + { + "status": "processed", + "updateId": 1532, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.251, + "enqueuedAt": "2022-02-01T14:52:03.756447300Z", + "processedAt": "2022-02-01T14:52:04.008705800Z" + }, + { + "status": "processed", + "updateId": 1533, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.25, + "enqueuedAt": "2022-02-01T14:52:04.390273200Z", + "processedAt": "2022-02-01T14:52:04.641732300Z" + }, + { + "status": "processed", + "updateId": 1534, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.242, + "enqueuedAt": "2022-02-01T14:52:04.989305400Z", + "processedAt": "2022-02-01T14:52:05.233113400Z" + }, + { + "status": "processed", + "updateId": 1535, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.23, + "enqueuedAt": "2022-02-01T14:52:05.576085300Z", + "processedAt": "2022-02-01T14:52:05.807720400Z" + }, + { + "status": "processed", + "updateId": 1536, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.197, + "enqueuedAt": "2022-02-01T14:52:06.174079600Z", + "processedAt": "2022-02-01T14:52:06.423792600Z" + }, + { + "status": "processed", + "updateId": 1537, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.189, + "enqueuedAt": "2022-02-01T14:52:06.861591900Z", + "processedAt": "2022-02-01T14:52:07.052136800Z" + }, + { + "status": "processed", + "updateId": 1538, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.259, + "enqueuedAt": "2022-02-01T14:52:07.547115700Z", + "processedAt": "2022-02-01T14:52:07.808132200Z" + }, + { + "status": "processed", + "updateId": 1539, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.212, + "enqueuedAt": "2022-02-01T14:52:08.279090500Z", + "processedAt": "2022-02-01T14:52:08.493362400Z" + }, + { + "status": "processed", + "updateId": 1540, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.273, + "enqueuedAt": "2022-02-01T14:52:09.056179500Z", + "processedAt": "2022-02-01T14:52:09.330449300Z" + }, + { + "status": "processed", + "updateId": 1541, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.27, + "enqueuedAt": "2022-02-01T14:52:09.731887Z", + "processedAt": "2022-02-01T14:52:10.003655600Z" + }, + { + "status": "processed", + "updateId": 1542, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.248, + "enqueuedAt": "2022-02-01T14:52:10.328825800Z", + "processedAt": "2022-02-01T14:52:10.578874800Z" + }, + { + "status": "processed", + "updateId": 1543, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.279, + "enqueuedAt": "2022-02-01T14:52:10.993175700Z", + "processedAt": "2022-02-01T14:52:11.274175400Z" + }, + { + "status": "processed", + "updateId": 1544, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.293, + "enqueuedAt": "2022-02-01T14:52:11.546402400Z", + "processedAt": "2022-02-01T14:52:11.840662200Z" + }, + { + "status": "processed", + "updateId": 1545, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.314, + "enqueuedAt": "2022-02-01T14:52:12.202740900Z", + "processedAt": "2022-02-01T14:52:12.518773400Z" + }, + { + "status": "processed", + "updateId": 1546, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.341, + "enqueuedAt": "2022-02-01T14:52:12.933348400Z", + "processedAt": "2022-02-01T14:52:13.275697300Z" + }, + { + "status": "processed", + "updateId": 1547, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.332, + "enqueuedAt": "2022-02-01T14:52:13.680008700Z", + "processedAt": "2022-02-01T14:52:14.013091200Z" + }, + { + "status": "processed", + "updateId": 1548, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.312, + "enqueuedAt": "2022-02-01T14:52:14.398538300Z", + "processedAt": "2022-02-01T14:52:14.712228100Z" + }, + { + "status": "processed", + "updateId": 1549, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.35, + "enqueuedAt": "2022-02-01T14:52:15.118608800Z", + "processedAt": "2022-02-01T14:52:15.469480200Z" + }, + { + "status": "processed", + "updateId": 1550, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.366, + "enqueuedAt": "2022-02-01T14:52:15.889378300Z", + "processedAt": "2022-02-01T14:52:16.256608700Z" + }, + { + "status": "processed", + "updateId": 1551, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.259, + "enqueuedAt": "2022-02-01T14:52:16.435391400Z", + "processedAt": "2022-02-01T14:52:16.695939800Z" + }, + { + "status": "processed", + "updateId": 1552, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.368, + "enqueuedAt": "2022-02-01T14:52:17.060250700Z", + "processedAt": "2022-02-01T14:52:17.429805100Z" + }, + { + "status": "processed", + "updateId": 1553, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.348, + "enqueuedAt": "2022-02-01T14:52:17.893990100Z", + "processedAt": "2022-02-01T14:52:18.243456Z" + }, + { + "status": "processed", + "updateId": 1554, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.386, + "enqueuedAt": "2022-02-01T14:52:18.539545Z", + "processedAt": "2022-02-01T14:52:18.927737800Z" + }, + { + "status": "processed", + "updateId": 1555, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.251, + "enqueuedAt": "2022-02-01T14:52:19.251134500Z", + "processedAt": "2022-02-01T14:52:19.503674Z" + }, + { + "status": "processed", + "updateId": 1556, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.28, + "enqueuedAt": "2022-02-01T14:52:19.973000400Z", + "processedAt": "2022-02-01T14:52:20.254326100Z" + }, + { + "status": "processed", + "updateId": 1557, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.247, + "enqueuedAt": "2022-02-01T14:52:20.648094300Z", + "processedAt": "2022-02-01T14:52:20.896989800Z" + }, + { + "status": "processed", + "updateId": 1558, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.287, + "enqueuedAt": "2022-02-01T14:52:21.261604100Z", + "processedAt": "2022-02-01T14:52:21.550672800Z" + }, + { + "status": "processed", + "updateId": 1559, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.256, + "enqueuedAt": "2022-02-01T14:52:21.964004500Z", + "processedAt": "2022-02-01T14:52:22.221491900Z" + }, + { + "status": "processed", + "updateId": 1560, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.242, + "enqueuedAt": "2022-02-01T14:52:22.577306900Z", + "processedAt": "2022-02-01T14:52:22.820913300Z" + }, + { + "status": "processed", + "updateId": 1561, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.242, + "enqueuedAt": "2022-02-01T14:52:23.125509Z", + "processedAt": "2022-02-01T14:52:23.369192100Z" + }, + { + "status": "processed", + "updateId": 1562, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.246, + "enqueuedAt": "2022-02-01T14:52:23.728729500Z", + "processedAt": "2022-02-01T14:52:23.976635500Z" + }, + { + "status": "processed", + "updateId": 1563, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.297, + "enqueuedAt": "2022-02-01T14:52:26.958012300Z", + "processedAt": "2022-02-01T14:52:27.256738Z" + }, + { + "status": "processed", + "updateId": 1564, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.314, + "enqueuedAt": "2022-02-01T14:52:27.671186400Z", + "processedAt": "2022-02-01T14:52:27.986994200Z" + }, + { + "status": "processed", + "updateId": 1565, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.273, + "enqueuedAt": "2022-02-01T14:52:28.281380900Z", + "processedAt": "2022-02-01T14:52:28.556341300Z" + }, + { + "status": "processed", + "updateId": 1566, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.266, + "enqueuedAt": "2022-02-01T14:52:28.886583800Z", + "processedAt": "2022-02-01T14:52:29.154610700Z" + }, + { + "status": "processed", + "updateId": 1567, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.283, + "enqueuedAt": "2022-02-01T14:52:29.506855200Z", + "processedAt": "2022-02-01T14:52:29.791927400Z" + }, + { + "status": "processed", + "updateId": 1568, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.326, + "enqueuedAt": "2022-02-01T14:52:30.112155700Z", + "processedAt": "2022-02-01T14:52:30.439752Z" + }, + { + "status": "processed", + "updateId": 1569, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.278, + "enqueuedAt": "2022-02-01T14:52:30.818053300Z", + "processedAt": "2022-02-01T14:52:31.098050600Z" + }, + { + "status": "processed", + "updateId": 1570, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.247, + "enqueuedAt": "2022-02-01T14:52:31.470906700Z", + "processedAt": "2022-02-01T14:52:31.719713900Z" + }, + { + "status": "processed", + "updateId": 1571, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.255, + "enqueuedAt": "2022-02-01T14:52:32.161437700Z", + "processedAt": "2022-02-01T14:52:32.418380900Z" + }, + { + "status": "processed", + "updateId": 1572, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.343, + "enqueuedAt": "2022-02-01T14:52:32.819785500Z", + "processedAt": "2022-02-01T14:52:33.164601400Z" + }, + { + "status": "processed", + "updateId": 1573, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.308, + "enqueuedAt": "2022-02-01T14:52:33.467821900Z", + "processedAt": "2022-02-01T14:52:33.777039500Z" + }, + { + "status": "processed", + "updateId": 1574, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.316, + "enqueuedAt": "2022-02-01T14:52:34.128264200Z", + "processedAt": "2022-02-01T14:52:34.446153200Z" + }, + { + "status": "processed", + "updateId": 1575, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.263, + "enqueuedAt": "2022-02-01T14:52:34.730751500Z", + "processedAt": "2022-02-01T14:52:34.994937900Z" + }, + { + "status": "processed", + "updateId": 1576, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.265, + "enqueuedAt": "2022-02-01T14:52:35.283693800Z", + "processedAt": "2022-02-01T14:52:35.550574100Z" + }, + { + "status": "processed", + "updateId": 1577, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.277, + "enqueuedAt": "2022-02-01T14:52:35.999214300Z", + "processedAt": "2022-02-01T14:52:36.277878300Z" + }, + { + "status": "processed", + "updateId": 1578, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.297, + "enqueuedAt": "2022-02-01T14:52:36.555038100Z", + "processedAt": "2022-02-01T14:52:36.854449100Z" + }, + { + "status": "processed", + "updateId": 1579, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.331, + "enqueuedAt": "2022-02-01T14:52:37.272906400Z", + "processedAt": "2022-02-01T14:52:37.605313700Z" + }, + { + "status": "processed", + "updateId": 1580, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.295, + "enqueuedAt": "2022-02-01T14:52:37.975168400Z", + "processedAt": "2022-02-01T14:52:38.272106400Z" + }, + { + "status": "processed", + "updateId": 1581, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.404, + "enqueuedAt": "2022-02-01T14:52:38.635686200Z", + "processedAt": "2022-02-01T14:52:39.041544100Z" + }, + { + "status": "processed", + "updateId": 1582, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.294, + "enqueuedAt": "2022-02-01T14:52:39.318050300Z", + "processedAt": "2022-02-01T14:52:39.613946100Z" + }, + { + "status": "processed", + "updateId": 1583, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.282, + "enqueuedAt": "2022-02-01T14:52:39.932872500Z", + "processedAt": "2022-02-01T14:52:40.216139800Z" + }, + { + "status": "processed", + "updateId": 1584, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.278, + "enqueuedAt": "2022-02-01T14:52:40.591292Z", + "processedAt": "2022-02-01T14:52:40.871379400Z" + }, + { + "status": "processed", + "updateId": 1585, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.319, + "enqueuedAt": "2022-02-01T14:52:41.239498600Z", + "processedAt": "2022-02-01T14:52:41.560028800Z" + }, + { + "status": "processed", + "updateId": 1586, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.305, + "enqueuedAt": "2022-02-01T14:52:41.868886500Z", + "processedAt": "2022-02-01T14:52:42.175718500Z" + }, + { + "status": "processed", + "updateId": 1587, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.271, + "enqueuedAt": "2022-02-01T14:52:42.512069900Z", + "processedAt": "2022-02-01T14:52:42.784768600Z" + }, + { + "status": "processed", + "updateId": 1588, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.291, + "enqueuedAt": "2022-02-01T14:52:43.111734500Z", + "processedAt": "2022-02-01T14:52:43.404553400Z" + }, + { + "status": "processed", + "updateId": 1589, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.277, + "enqueuedAt": "2022-02-01T14:52:43.707600500Z", + "processedAt": "2022-02-01T14:52:43.986074700Z" + }, + { + "status": "processed", + "updateId": 1590, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.284, + "enqueuedAt": "2022-02-01T14:52:44.381509400Z", + "processedAt": "2022-02-01T14:52:44.667283600Z" + }, + { + "status": "processed", + "updateId": 1591, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.296, + "enqueuedAt": "2022-02-01T14:52:45.050156700Z", + "processedAt": "2022-02-01T14:52:45.347288600Z" + }, + { + "status": "processed", + "updateId": 1592, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.31, + "enqueuedAt": "2022-02-01T14:52:45.705994600Z", + "processedAt": "2022-02-01T14:52:46.017577200Z" + }, + { + "status": "processed", + "updateId": 1593, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.292, + "enqueuedAt": "2022-02-01T14:52:46.304721400Z", + "processedAt": "2022-02-01T14:52:46.598132Z" + }, + { + "status": "processed", + "updateId": 1594, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.277, + "enqueuedAt": "2022-02-01T14:52:46.959903Z", + "processedAt": "2022-02-01T14:52:47.238801200Z" + }, + { + "status": "processed", + "updateId": 1595, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.283, + "enqueuedAt": "2022-02-01T14:52:47.631649600Z", + "processedAt": "2022-02-01T14:52:47.915896300Z" + }, + { + "status": "failed", + "updateId": 1596, + "type": { + "name": "DocumentsAddition" + }, + "error": { + "message": "Document identifier `` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_).", + "code": "invalid_document_id", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_document_id" + }, + "duration": 0, + "enqueuedAt": "2022-02-01T14:52:48.206972Z", + "processedAt": "2022-02-01T14:52:48.209242100Z" + }, + { + "status": "processed", + "updateId": 1597, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.387, + "enqueuedAt": "2022-02-01T14:52:48.911642400Z", + "processedAt": "2022-02-01T14:52:49.300097900Z" + }, + { + "status": "processed", + "updateId": 1598, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.403, + "enqueuedAt": "2022-02-01T14:52:49.574968900Z", + "processedAt": "2022-02-01T14:52:49.978720900Z" + }, + { + "status": "processed", + "updateId": 1599, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.314, + "enqueuedAt": "2022-02-01T14:52:50.261800800Z", + "processedAt": "2022-02-01T14:52:50.577481800Z" + }, + { + "status": "processed", + "updateId": 1600, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.357, + "enqueuedAt": "2022-02-01T14:52:50.891616400Z", + "processedAt": "2022-02-01T14:52:51.249810100Z" + }, + { + "status": "processed", + "updateId": 1601, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.299, + "enqueuedAt": "2022-02-01T14:52:51.490122Z", + "processedAt": "2022-02-01T14:52:51.790460600Z" + }, + { + "status": "processed", + "updateId": 1602, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.364, + "enqueuedAt": "2022-02-01T14:52:52.144238300Z", + "processedAt": "2022-02-01T14:52:52.509156500Z" + }, + { + "status": "processed", + "updateId": 1603, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.372, + "enqueuedAt": "2022-02-01T14:52:52.774284600Z", + "processedAt": "2022-02-01T14:52:53.148024200Z" + }, + { + "status": "processed", + "updateId": 1604, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.344, + "enqueuedAt": "2022-02-01T14:52:53.335672800Z", + "processedAt": "2022-02-01T14:52:53.681215300Z" + }, + { + "status": "processed", + "updateId": 1605, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 2.995, + "enqueuedAt": "2022-02-01T14:52:53.939606100Z", + "processedAt": "2022-02-01T14:52:56.936335Z" + }, + { + "status": "processed", + "updateId": 1606, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.309, + "enqueuedAt": "2022-02-01T14:52:57.320612200Z", + "processedAt": "2022-02-01T14:52:57.631646200Z" + }, + { + "status": "processed", + "updateId": 1607, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.328, + "enqueuedAt": "2022-02-01T14:52:57.967443900Z", + "processedAt": "2022-02-01T14:52:58.297247400Z" + }, + { + "status": "processed", + "updateId": 1608, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.37, + "enqueuedAt": "2022-02-01T14:52:58.833407100Z", + "processedAt": "2022-02-01T14:52:59.205626900Z" + }, + { + "status": "processed", + "updateId": 1609, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.321, + "enqueuedAt": "2022-02-01T14:52:59.524668400Z", + "processedAt": "2022-02-01T14:52:59.847698100Z" + }, + { + "status": "processed", + "updateId": 1610, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.31, + "enqueuedAt": "2022-02-01T14:53:00.177503600Z", + "processedAt": "2022-02-01T14:53:00.489694200Z" + }, + { + "status": "processed", + "updateId": 1611, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.33, + "enqueuedAt": "2022-02-01T14:53:00.720140Z", + "processedAt": "2022-02-01T14:53:01.051270600Z" + }, + { + "status": "processed", + "updateId": 1612, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.39, + "enqueuedAt": "2022-02-01T14:53:01.435512800Z", + "processedAt": "2022-02-01T14:53:01.826911500Z" + }, + { + "status": "processed", + "updateId": 1613, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.356, + "enqueuedAt": "2022-02-01T14:53:02.128305200Z", + "processedAt": "2022-02-01T14:53:02.485402600Z" + }, + { + "status": "processed", + "updateId": 1614, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.392, + "enqueuedAt": "2022-02-01T14:53:02.847348100Z", + "processedAt": "2022-02-01T14:53:03.240652500Z" + }, + { + "status": "processed", + "updateId": 1615, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.292, + "enqueuedAt": "2022-02-01T14:53:03.524195300Z", + "processedAt": "2022-02-01T14:53:03.817827600Z" + }, + { + "status": "processed", + "updateId": 1616, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.333, + "enqueuedAt": "2022-02-01T14:53:04.154340400Z", + "processedAt": "2022-02-01T14:53:04.488645600Z" + }, + { + "status": "processed", + "updateId": 1617, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.297, + "enqueuedAt": "2022-02-01T14:53:04.778825400Z", + "processedAt": "2022-02-01T14:53:05.077521100Z" + }, + { + "status": "processed", + "updateId": 1618, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.314, + "enqueuedAt": "2022-02-01T14:53:05.430804700Z", + "processedAt": "2022-02-01T14:53:05.747252200Z" + }, + { + "status": "processed", + "updateId": 1619, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.433, + "enqueuedAt": "2022-02-01T14:53:06.059600200Z", + "processedAt": "2022-02-01T14:53:06.495666500Z" + }, + { + "status": "processed", + "updateId": 1620, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.438, + "enqueuedAt": "2022-02-01T14:53:06.764791400Z", + "processedAt": "2022-02-01T14:53:07.204459700Z" + }, + { + "status": "processed", + "updateId": 1621, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.393, + "enqueuedAt": "2022-02-01T14:53:07.546992400Z", + "processedAt": "2022-02-01T14:53:07.941821300Z" + }, + { + "status": "processed", + "updateId": 1622, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.365, + "enqueuedAt": "2022-02-01T14:53:08.247317300Z", + "processedAt": "2022-02-01T14:53:08.614088500Z" + }, + { + "status": "processed", + "updateId": 1623, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.48, + "enqueuedAt": "2022-02-01T14:53:08.996793200Z", + "processedAt": "2022-02-01T14:53:09.478533700Z" + }, + { + "status": "processed", + "updateId": 1624, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.408, + "enqueuedAt": "2022-02-01T14:53:09.738593200Z", + "processedAt": "2022-02-01T14:53:10.148236400Z" + }, + { + "status": "processed", + "updateId": 1625, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.336, + "enqueuedAt": "2022-02-01T14:53:10.374750600Z", + "processedAt": "2022-02-01T14:53:10.711984700Z" + }, + { + "status": "processed", + "updateId": 1626, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.296, + "enqueuedAt": "2022-02-01T14:53:10.973615800Z", + "processedAt": "2022-02-01T14:53:11.271271100Z" + }, + { + "status": "processed", + "updateId": 1627, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.313, + "enqueuedAt": "2022-02-01T14:53:11.572258400Z", + "processedAt": "2022-02-01T14:53:11.887076700Z" + }, + { + "status": "processed", + "updateId": 1628, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.326, + "enqueuedAt": "2022-02-01T14:53:12.198247500Z", + "processedAt": "2022-02-01T14:53:12.525924100Z" + }, + { + "status": "processed", + "updateId": 1629, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.326, + "enqueuedAt": "2022-02-01T14:53:12.837782700Z", + "processedAt": "2022-02-01T14:53:13.164756900Z" + }, + { + "status": "processed", + "updateId": 1630, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.37, + "enqueuedAt": "2022-02-01T14:53:13.447464900Z", + "processedAt": "2022-02-01T14:53:13.818957100Z" + }, + { + "status": "processed", + "updateId": 1631, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.316, + "enqueuedAt": "2022-02-01T14:53:14.104922800Z", + "processedAt": "2022-02-01T14:53:14.423086500Z" + }, + { + "status": "processed", + "updateId": 1632, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.344, + "enqueuedAt": "2022-02-01T14:53:14.760831700Z", + "processedAt": "2022-02-01T14:53:15.106634700Z" + }, + { + "status": "processed", + "updateId": 1633, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.364, + "enqueuedAt": "2022-02-01T14:53:15.371012800Z", + "processedAt": "2022-02-01T14:53:15.736827300Z" + }, + { + "status": "processed", + "updateId": 1634, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.379, + "enqueuedAt": "2022-02-01T14:53:16.097360200Z", + "processedAt": "2022-02-01T14:53:16.478989500Z" + }, + { + "status": "processed", + "updateId": 1635, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.326, + "enqueuedAt": "2022-02-01T14:53:16.877721Z", + "processedAt": "2022-02-01T14:53:17.205939400Z" + }, + { + "status": "processed", + "updateId": 1636, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.308, + "enqueuedAt": "2022-02-01T14:53:17.460913900Z", + "processedAt": "2022-02-01T14:53:17.770766300Z" + }, + { + "status": "processed", + "updateId": 1637, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.343, + "enqueuedAt": "2022-02-01T14:53:18.154929900Z", + "processedAt": "2022-02-01T14:53:18.499226300Z" + }, + { + "status": "processed", + "updateId": 1638, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.3, + "enqueuedAt": "2022-02-01T14:53:18.810355500Z", + "processedAt": "2022-02-01T14:53:19.112148100Z" + }, + { + "status": "processed", + "updateId": 1639, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.327, + "enqueuedAt": "2022-02-01T14:53:19.443235200Z", + "processedAt": "2022-02-01T14:53:19.771439800Z" + }, + { + "status": "processed", + "updateId": 1640, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.258, + "enqueuedAt": "2022-02-01T14:53:20.043912400Z", + "processedAt": "2022-02-01T14:53:20.303444800Z" + }, + { + "status": "processed", + "updateId": 1641, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.34, + "enqueuedAt": "2022-02-01T14:53:20.654730600Z", + "processedAt": "2022-02-01T14:53:20.997494800Z" + }, + { + "status": "failed", + "updateId": 1642, + "type": { + "name": "DocumentsAddition" + }, + "error": { + "message": "Document identifier `` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_).", + "code": "invalid_document_id", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_document_id" + }, + "duration": 0, + "enqueuedAt": "2022-02-01T14:53:21.196425500Z", + "processedAt": "2022-02-01T14:53:21.198243100Z" + }, + { + "status": "processed", + "updateId": 1643, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.259, + "enqueuedAt": "2022-02-01T14:53:21.763274500Z", + "processedAt": "2022-02-01T14:53:22.023963400Z" + }, + { + "status": "processed", + "updateId": 1644, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.433, + "enqueuedAt": "2022-02-01T14:53:22.379220700Z", + "processedAt": "2022-02-01T14:53:22.813731500Z" + }, + { + "status": "processed", + "updateId": 1645, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 0.312, + "enqueuedAt": "2022-02-01T14:53:23.190357300Z", + "processedAt": "2022-02-01T14:53:23.504134700Z" + }, + { + "status": "processed", + "updateId": 1646, + "type": { + "name": "DocumentsAddition", + "number": 1 + }, + "duration": 2.375, + "enqueuedAt": "2022-02-01T14:53:23.842169300Z", + "processedAt": "2022-02-01T14:53:26.219457700Z" + }, + { + "status": "processed", + "updateId": 1647, + "type": { + "name": "Settings", + "settings": { + "filterableAttributes": [ + "tags" + ] + } + }, + "duration": 0.008, + "enqueuedAt": "2022-02-01T14:53:28.938385100Z", + "processedAt": "2022-02-01T14:53:28.947932Z" + } +] diff --git a/bin/md-functions.sh b/bin/md-functions.sh new file mode 100755 index 0000000..01b7bff --- /dev/null +++ b/bin/md-functions.sh @@ -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 + diff --git a/bin/neorg-pandoc-linux86 b/bin/neorg-pandoc-linux86 new file mode 100755 index 0000000..e7345c1 Binary files /dev/null and b/bin/neorg-pandoc-linux86 differ diff --git a/bin/norg-functions.sh b/bin/norg-functions.sh new file mode 100755 index 0000000..338023e --- /dev/null +++ b/bin/norg-functions.sh @@ -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 diff --git a/bin/project.sh b/bin/project.sh new file mode 100644 index 0000000..d295ee2 --- /dev/null +++ b/bin/project.sh @@ -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 diff --git a/bin/sshconnect.sh b/bin/sshconnect.sh new file mode 100755 index 0000000..c338778 --- /dev/null +++ b/bin/sshconnect.sh @@ -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" diff --git a/bin/test.sh b/bin/test.sh new file mode 100644 index 0000000..f5e72cb --- /dev/null +++ b/bin/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +test01="ett" +echo $test01 +test01="två" +echo $test01 + diff --git a/bin/updateNotes.sh b/bin/updateNotes.sh new file mode 100755 index 0000000..f72364d --- /dev/null +++ b/bin/updateNotes.sh @@ -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 diff --git a/bin/xmllint_local-name.sh b/bin/xmllint_local-name.sh new file mode 100755 index 0000000..cc44ec6 --- /dev/null +++ b/bin/xmllint_local-name.sh @@ -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}"