From 0c4f5418a01069d7a049ec92d038dea33856a413 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 1 Mar 2022 11:49:59 +0200 Subject: [PATCH] feat: more volume aliases --- .pnpm-debug.log | 37 +++--------------- dotfiles/neovim/lua/my/plugins/cmp.lua | 52 ++++++++++++++++--------- modules/applications/misc.nix | 2 +- modules/applications/neovim.nix | 6 ++- modules/applications/shells/aliases.nix | 9 ++++- 5 files changed, 50 insertions(+), 56 deletions(-) diff --git a/.pnpm-debug.log b/.pnpm-debug.log index 8d8f149..934d140 100644 --- a/.pnpm-debug.log +++ b/.pnpm-debug.log @@ -2,40 +2,13 @@ "0 debug pnpm:scope": { "selected": 1 }, - "1 debug pnpm:package-manifest": { - "initial": {}, - "prefix": "/home/adrielus/Projects/nixos-config" - }, - "2 debug pnpm:context": { - "currentLockfileExists": false, - "storeDir": "/home/adrielus/.pnpm-store/v3", - "virtualStoreDir": "/home/adrielus/Projects/nixos-config/node_modules/.pnpm" - }, - "3 debug pnpm:stage": { - "prefix": "/home/adrielus/Projects/nixos-config", - "stage": "resolution_started" - }, - "4 debug pnpm:update-check": { - "currentVersion": "6.22.2", - "latestVersion": "6.29.1" - }, - "5 error pnpm": { - "code": "ERR_PNPM_FETCH_404", - "hint": "prettierd is not in the npm registry, or you have no permission to fetch it.\n\nAn authorization header was used: Bearer 265b[hidden]", - "request": { - "authHeaderValue": "Bearer 265ba49b-cc14-402e-8c57-e070a7bc1997", - "url": "https://registry.npmjs.org/prettierd" - }, - "response": { - "size": 0 - }, - "pkgName": "prettierd", - "pkgsStack": [], + "1 error pnpm": { + "code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND", "err": { "name": "pnpm", - "message": "GET https://registry.npmjs.org/prettierd: Not Found - 404", - "code": "ERR_PNPM_FETCH_404", - "stack": "pnpm: GET https://registry.npmjs.org/prettierd: Not Found - 404\n at RetryOperation._fn (/nix/store/kh5rqvj2l82gznih1b5isc43mk2dnh6j-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:84952:18)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)" + "message": "No package.json (or package.yaml, or package.json5) was found in \"/home/adrielus/Projects/nixos-config\".", + "code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND", + "stack": "pnpm: No package.json (or package.yaml, or package.json5) was found in \"/home/adrielus/Projects/nixos-config\".\n at readProjectManifest (/nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:43046:13)\n at async Object.readProjectManifestOnly (/nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:43050:28)\n at async readProjectManifestOnly (/nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:43269:24)\n at async Object.handler (/nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:129915:24)\n at async /nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:134121:20\n at async run (/nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:134095:34)\n at async runPnpm (/nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:134307:5)\n at async /nix/store/iigpa453qi2achcz6mq83bnwif8m42mj-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:134299:7" } } } \ No newline at end of file diff --git a/dotfiles/neovim/lua/my/plugins/cmp.lua b/dotfiles/neovim/lua/my/plugins/cmp.lua index 07d322e..7cea831 100644 --- a/dotfiles/neovim/lua/my/plugins/cmp.lua +++ b/dotfiles/neovim/lua/my/plugins/cmp.lua @@ -1,6 +1,6 @@ local M = {} -local function has_words_before () +local function has_words_before() local line, col = 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 @@ -8,8 +8,16 @@ end function M.setup() local cmp = require("cmp") local lspkind = require('lspkind') + local luasnip = require("luasnip") + local options = { formatting = {format = lspkind.cmp_format()}, + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, mapping = { [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}), @@ -17,28 +25,34 @@ function M.setup() [''] = cmp.config.disable, [''] = cmp.mapping({i = cmp.mapping.abort(), c = cmp.mapping.close()}), [''] = cmp.mapping.confirm({select = true}), - -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings + -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings [''] = cmp.mapping.confirm {behavior = cmp.ConfirmBehavior.Insert, select = true}, - [''] = function(fallback) - if not cmp.select_next_item() then - if vim.bo.buftype ~= 'prompt' and has_words_before() then - cmp.complete() - else - fallback() - end + -- TODO: abstract booth of those away perhaps? + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() end - end, - [''] = function(fallback) - if not cmp.select_prev_item() then - if vim.bo.buftype ~= 'prompt' and has_words_before() then - cmp.complete() - else - fallback() - end + end, {"i", "s"}), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() end - end, + end, {"i", "s"}) }, - sources = cmp.config.sources({{name = 'nvim_lsp'}}, {{name = 'buffer'}}) + sources = cmp.config.sources({ + {name = 'nvim_lsp'}, -- lsp completion + {name = 'luasnip'} -- snippets + }, {{name = 'buffer'}}) } cmp.setup(options) diff --git a/modules/applications/misc.nix b/modules/applications/misc.nix index 3314fad..827ef4f 100644 --- a/modules/applications/misc.nix +++ b/modules/applications/misc.nix @@ -70,7 +70,7 @@ # fceux # games - # tetrio-desktop + tetrio-desktop # mindustry # edopro ]; diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index dd7d8f3..da66474 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -56,14 +56,16 @@ in null-ls-nvim # generic language server telescope-file-browser-nvim # file creation/deletion using telescope lspkind-nvim # show icons in lsp completion menus - symbols-outline-nvim # tree view for symbols in document + # symbols-outline-nvim # tree view for symbols in document # Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp cmp-nvim-lsp cmp-buffer cmp-path cmp-cmdline - nvim-cmp + cmp_luasnip + nvim-cmp # completion engine + luasnip # snippet engine ]; }; } diff --git a/modules/applications/shells/aliases.nix b/modules/applications/shells/aliases.nix index 6433d58..114612d 100644 --- a/modules/applications/shells/aliases.nix +++ b/modules/applications/shells/aliases.nix @@ -1,13 +1,18 @@ { + # Ls but looks nicer ls = "exa -la"; + + # What even is this??? sl = "sl -e"; # WIfi stuff wifi = "sudo nmcli con up id"; # Volume controls - vup = "amixer set Master 8%+"; - vdown = "amixer set Master 8%-"; + "v up" = "amixer set Master 8%+"; + "v down" = "amixer set Master 8%-"; + "v min" = "amixer set Master 0%"; + "v max" = "amixer set Master 100%"; # Rebuuild nixos rebuild = "sudo nixos-rebuild switch --flake ~/Projects/nixos-config/";