From ceded2bb2a3a630169b3ebe0582b461138ed4a9c Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 1 Mar 2022 23:25:44 +0100 Subject: [PATCH] feat: friendly snippets for ultisnips --- .luarc.json | 7 ++++ configs/.zshrc | 1 + configs/nvim/init.lua | 8 +++++ configs/nvim/lua/autocommands.lua | 8 +++++ configs/nvim/lua/cmp-conf.lua | 1 - configs/nvim/lua/keymappings.lua | 1 + configs/nvim/lua/lsp-conf.lua | 29 +++++++++------ configs/nvim/lua/plugins.lua | 3 +- configs/nvim/lua/snippets.lua | 60 ++++++++++++++++--------------- configs/nvim/spell/dictionary.txt | 0 configs/nvim/spell/disable.txt | 0 configs/nvim/spell/false.txt | 0 configs/sway/config | 23 ++++++++---- configs/sway/lock_screen.sh | 12 +------ configs/wofi/wofi-power-menu.sh | 2 +- configs/zsh/aliases.sh | 7 ++-- configs/zsh/functions.zsh | 2 ++ configs/zsh/functions/dv.zsh | 13 +++++++ configs/zsh/functions/run.zsh | 11 ++++++ 19 files changed, 126 insertions(+), 62 deletions(-) create mode 100644 .luarc.json create mode 100644 configs/nvim/spell/dictionary.txt create mode 100644 configs/nvim/spell/disable.txt create mode 100644 configs/nvim/spell/false.txt create mode 100644 configs/zsh/functions/dv.zsh create mode 100644 configs/zsh/functions/run.zsh diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..f20f688 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.diagnostics.globals": [ + "require", + "vim" + ] +} \ No newline at end of file diff --git a/configs/.zshrc b/configs/.zshrc index 4eaca3a..6b814eb 100644 --- a/configs/.zshrc +++ b/configs/.zshrc @@ -21,6 +21,7 @@ plugins=( eval `dircolors ~/.dircolors` export FPATH=$FPATH:~/.dotfiles/completions +export NVIM_HOME=$HOME/.config/nvim # Load oh my zsh export ZSH=~/.oh-my-zsh diff --git a/configs/nvim/init.lua b/configs/nvim/init.lua index bdbb566..2435540 100644 --- a/configs/nvim/init.lua +++ b/configs/nvim/init.lua @@ -85,6 +85,12 @@ if u.has_plugin("cmp") then } ) + vim.wo.foldmethod = "expr" + vim.wo.foldexpr = "nvim_treesitter#foldexpr()" + vim.cmd [[ + set foldlevel=99 + ]] + require("telescope").setup { defaults = { vimgrep_arguments = { @@ -154,6 +160,8 @@ if u.has_plugin("cmp") then } ) + g.markdown_fenced_languages = {"html", "python", "bash=sh"} + -- Remove background color cmd("highlight Normal guibg=none") cmd("highlight NonText guibg=none") diff --git a/configs/nvim/lua/autocommands.lua b/configs/nvim/lua/autocommands.lua index fc75171..b999f0b 100644 --- a/configs/nvim/lua/autocommands.lua +++ b/configs/nvim/lua/autocommands.lua @@ -11,3 +11,11 @@ cmd [[ au ColorScheme * hi Normal ctermbg=none guibg=none au ColorScheme myspecialcolors hi Normal ctermbg=red guibg=red ]] + +cmd [[ +augroup SaveManualFolds + autocmd! + au BufWinLeave, BufLeave ?* silent! mkview + au BufWinEnter ?* silent! loadview +augroup END +]] diff --git a/configs/nvim/lua/cmp-conf.lua b/configs/nvim/lua/cmp-conf.lua index aad3da2..7c84973 100644 --- a/configs/nvim/lua/cmp-conf.lua +++ b/configs/nvim/lua/cmp-conf.lua @@ -1,5 +1,4 @@ -- luasnip setup -local cmd = vim.cmd local luasnip = require "luasnip" local lspkind = require "lspkind" local cmp = require "cmp" diff --git a/configs/nvim/lua/keymappings.lua b/configs/nvim/lua/keymappings.lua index 207a9d6..92038e6 100644 --- a/configs/nvim/lua/keymappings.lua +++ b/configs/nvim/lua/keymappings.lua @@ -9,6 +9,7 @@ g.mapleader = " " map("n", "", ":Telescope find_files", options) map("n", "", ":Telescope live_grep", options) +map("n", "", "za", options) -- LSP Functionality map("n", "gD", "lua vim.lsp.buf.declaration()", options) diff --git a/configs/nvim/lua/lsp-conf.lua b/configs/nvim/lua/lsp-conf.lua index bb70273..34c2415 100644 --- a/configs/nvim/lua/lsp-conf.lua +++ b/configs/nvim/lua/lsp-conf.lua @@ -49,18 +49,27 @@ require "lspconfig".sumneko_lua.setup { } -- Ltex Language Server -lsp.ltex.setup { - ltex = { - completionEnabled = true, - language = {"de", "en", "es"}, - configurationTarget = {}, - statusBarItem = true, - dictionary = { - ["de"] = {"~/test.txt"}, - ["en"] = {"~/test.txt"} +require("grammar-guard").init() +-- setup LSP config +require("lspconfig").grammar_guard.setup( + { + cmd = {vim.fn.expand("~/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls")}, + settings = { + ltex = { + enabled = {"latex", "tex", "bib", "markdown"}, + language = "de", + diagnosticSeverity = "information", + additionalRules = { + enablePickyRules = true, + motherTongue = "de" + }, + dictionary = {}, + disabledRules = {}, + hiddenFalsePositives = {} + } } } -} +) -- Go Language Server lsp.gopls.setup { diff --git a/configs/nvim/lua/plugins.lua b/configs/nvim/lua/plugins.lua index 230adae..ea949d3 100644 --- a/configs/nvim/lua/plugins.lua +++ b/configs/nvim/lua/plugins.lua @@ -60,12 +60,13 @@ return require("packer").startup( use "hrsh7th/cmp-calc" use "hrsh7th/cmp-buffer" use "hrsh7th/cmp-cmdline" + use "rafamadriz/friendly-snippets" use "L3MON4D3/LuaSnip" use "saadparwaiz1/cmp_luasnip" - use "rafamadriz/friendly-snippets" use "williamboman/nvim-lsp-installer" use "nvim-lua/lsp-status.nvim" use "neoclide/jsonc.vim" + use "brymer-meneses/grammar-guard.nvim" use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" diff --git a/configs/nvim/lua/snippets.lua b/configs/nvim/lua/snippets.lua index c83f529..1f56a09 100644 --- a/configs/nvim/lua/snippets.lua +++ b/configs/nvim/lua/snippets.lua @@ -11,35 +11,39 @@ local d = ls.dynamic_node local types = require("luasnip.util.types") --- Every unspecified option will be set to the default. -ls.config.set_config({ - history = true, - -- Update more often, :h events for more info. - updateevents = "TextChanged,TextChangedI", - ext_opts = { - [types.choiceNode] = { - active = { - virt_text = { { "choiceNode", "Comment" } }, - }, - }, - }, - -- treesitter-hl has 100, use something higher (default is 200). - ext_base_prio = 300, - -- minimal increase in priority. - ext_prio_increase = 1, - enable_autosnippets = true, -}) +require("luasnip.loaders.from_vscode").load({include = {"typescript", "javascript", "html"}}) -- Load only python snippets +-- Every unspecified option will be set to the default. +ls.config.set_config( + { + history = true, + -- Update more often, :h events for more info. + updateevents = "TextChanged,TextChangedI", + ext_opts = { + [types.choiceNode] = { + active = { + virt_text = {{"choiceNode", "Comment"}} + } + } + }, + -- treesitter-hl has 100, use something higher (default is 200). + ext_base_prio = 300, + -- minimal increase in priority. + ext_prio_increase = 1, + enable_autosnippets = true + } +) ls.snippets = { - all = { - - }, - svelte = { - s("slt", { - t(''), - }), - } + all = {}, + svelte = { + s( + "slt", + { + t('") + } + ) + } } diff --git a/configs/nvim/spell/dictionary.txt b/configs/nvim/spell/dictionary.txt new file mode 100644 index 0000000..e69de29 diff --git a/configs/nvim/spell/disable.txt b/configs/nvim/spell/disable.txt new file mode 100644 index 0000000..e69de29 diff --git a/configs/nvim/spell/false.txt b/configs/nvim/spell/false.txt new file mode 100644 index 0000000..e69de29 diff --git a/configs/sway/config b/configs/sway/config index 53c0a8f..82c4cf3 100644 --- a/configs/sway/config +++ b/configs/sway/config @@ -1,4 +1,4 @@ -# vi: ft=conf +# vi: ft=confj # /go # Default config for sway @@ -7,7 +7,7 @@ # # Read `man 5 sway` for a complete reference. -exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway +exec export $(dbus-launch --exit-with-session); ### Variables # @@ -43,11 +43,13 @@ set $web_search $wofi_scripts/web-search.sh set $select_window ~/.config/sway/select_window.sh set $lock_screen ~/.config/sway/lock_screen.sh set $select_emoji $wofi_scripts/wofi-emoji +set $password_mngr rofi-rbw --selector wofi # Input configuration input * { xkb_layout de - xkb_variant nodeadkeys + xkb_capslock disabled + tap enabled } smart_gaps off @@ -108,7 +110,8 @@ exec swayidle -w \ bindsym $mod+b exec $browser bindsym $mod+Shift+Comma exec $config_editor bindsym $mod+a exec $web_search - + bindsym $mod+p exec $password_mngr + # Drag and resize floating windows with mouse right/left drag floating_modifier $mod normal @@ -116,9 +119,9 @@ exec swayidle -w \ bindsym $mod+Shift+c reload # Multimedia Audio Keys - bindsym XF86AudioMute exec "pactl list sinks | grep -q Mute:.no && pactl set-sink-mute 0 1 || pactl set-sink-mute 0 0" - bindsym XF86AudioLowerVolume exec "pactl -- set-sink-volume 0 -10%" - bindsym XF86AudioRaiseVolume exec "pactl -- set-sink-volume 0 +10%" + bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle + bindsym --locked XF86AudioLowerVolume exec "pactl -- set-sink-volume @DEFAULT_SINK@ -10%" + bindsym --locked XF86AudioRaiseVolume exec "pactl -- set-sink-volume @DEFAULT_SINK@ +10%" #Increase brightness bindsym XF86MonBrightnessUp exec brightnessctl -d intel_backlight set +10 @@ -269,12 +272,17 @@ mode "resize" { } bindsym $mod+r mode "resize" +exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK + # Do we need that? exec_always nm-applet --indicator # Handles notifications exec_always mako +exec_always wlsunset -l 39.47 -L -0.3821346 + + # # Status Bar: # @@ -284,3 +292,4 @@ bar { } include @sysconfdir@/sway/config.d/* +exec systemctl --user import-environment diff --git a/configs/sway/lock_screen.sh b/configs/sway/lock_screen.sh index c884636..e02d287 100755 --- a/configs/sway/lock_screen.sh +++ b/configs/sway/lock_screen.sh @@ -1,13 +1,3 @@ #!/usr/bin/sh -swaylock \ - --screenshots \ - --indicator-radius 500 \ - --effect-blur 7x5 \ - --effect-pixelate 7 \ - --ring-color ffffff \ - --line-color 000000 \ - --inside-color ffffff \ - --separator-color 00000000 \ - --grace 2 \ - --fade-in 2 +swaylock -c 000000 diff --git a/configs/wofi/wofi-power-menu.sh b/configs/wofi/wofi-power-menu.sh index aaf367c..1055a6f 100755 --- a/configs/wofi/wofi-power-menu.sh +++ b/configs/wofi/wofi-power-menu.sh @@ -12,5 +12,5 @@ case $selected in reboot) exec systemctl reboot;; shutdown) - exec systemctl poweroff -i;; + exec shutdown now;; esac diff --git a/configs/zsh/aliases.sh b/configs/zsh/aliases.sh index 24eed52..7799d69 100644 --- a/configs/zsh/aliases.sh +++ b/configs/zsh/aliases.sh @@ -25,9 +25,10 @@ alias gcm="git commit -m " alias czi="commitizen init cz-conventional-changelog --yarn --dev --exact" alias cz="git-cz" -alias D="pnpm dev" -alias B="pnpm build" -alias T="pnpm test" +alias D="run dev" +alias B="run build" +alias T="run test" + alias P="git push" alias p="git pull" diff --git a/configs/zsh/functions.zsh b/configs/zsh/functions.zsh index cc03150..555688c 100644 --- a/configs/zsh/functions.zsh +++ b/configs/zsh/functions.zsh @@ -8,3 +8,5 @@ source $(dirname "$0")/functions/sum.zsh; source $(dirname "$0")/functions/mke.zsh; source $(dirname "$0")/functions/myip.zsh; source $(dirname "$0")/functions/cht.zsh; +source $(dirname "$0")/functions/dv.zsh; +source $(dirname "$0")/functions/run.zsh; diff --git a/configs/zsh/functions/dv.zsh b/configs/zsh/functions/dv.zsh new file mode 100644 index 0000000..786458f --- /dev/null +++ b/configs/zsh/functions/dv.zsh @@ -0,0 +1,13 @@ +function dv(){ + tmux splitw -v -p20 + tmux splitw -h + # tmux splitw -p90 + # tmux splitw -dp22 # 20/90 + # tmux splitw -h + # tmux selectp -t'{right}' + # tmux splitw -p80 + # tmux splitw -p56 # (15+15+15)/80 + # tmux splitw -p50 + tmux selectp -t'{top-left}' + nvim . +} diff --git a/configs/zsh/functions/run.zsh b/configs/zsh/functions/run.zsh new file mode 100644 index 0000000..01b8c68 --- /dev/null +++ b/configs/zsh/functions/run.zsh @@ -0,0 +1,11 @@ +function run(){ + HAS_MAKE="$(ls | grep Makefile)" + HAS_PACKAGE="$(ls | grep package.json)" + + if [ "$HAS_PACKAGE" != "" ]; then + pnpm $1 + elif [ "$HAS_MAKE" != "" ]; then + make $1 + fi + +}