From c0210882237140d3f847416fe0213e6dd6fe4481 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 4 Mar 2022 18:48:07 +0100 Subject: [PATCH 01/52] [scripts] feat: bulk now defaults to OGG convertion --- .local/bin/bulk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/bulk b/.local/bin/bulk index 68470cf..82e6f50 100755 --- a/.local/bin/bulk +++ b/.local/bin/bulk @@ -11,5 +11,5 @@ [ $1 = "" ] && 1="mv -i" -[ $1 = "sox" ] && flags="-C 320" +[ $1 = "sox" ] && flags="-C 6" \ls | $EDITOR - -c ":%s/.*/$1 \"&\" $flags \"&\"/g" From f33c1ff1edb9ad8d10ee4c24b8d6e6d91798727d Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 4 Mar 2022 19:16:06 +0100 Subject: [PATCH 02/52] [dunst] feat: update config with upstream --- .config/dunst/dunstrc | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index aca8360..aad0cc1 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -38,13 +38,7 @@ # Scale factor. It is auto-detected if value is 0. scale = 0 - # Maximum number of notification (0 means no limit) - notification_limit = 0 - - ### Progress bar ### - - # Turn on the progess bar. It appears when a progress hint is passed with - # for example dunstify -h int:value:12 + # Turn on the progess bar progress_bar = true # Set the progress bar height. This includes the frame, so make sure @@ -237,16 +231,6 @@ # user defined timeout. ignore_dbusclose = false - ### Wayland ### - # These settings are Wayland-specific. They have no effect when using X11 - - # Uncomment this if you want to let notications appear under fullscreen - # applications (default: overlay) - # layer = top - - # Set this to true to use X11 output on Wayland. - force_xwayland = false - ### Legacy # Use the Xinerama extension instead of RandR for multi-monitor support. From 8b111f0f5842be0d2cfb0fa4446de2411ba7ec5c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 4 Mar 2022 19:16:40 +0100 Subject: [PATCH 03/52] [mbsync] fix: must precise where to store Inbox --- .config/mbsync/config | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/mbsync/config b/.config/mbsync/config index 621a9a6..79edeeb 100644 --- a/.config/mbsync/config +++ b/.config/mbsync/config @@ -90,6 +90,7 @@ CertificateFile /etc/ssl/certs/ca-certificates.crt MaildirStore david.julien@centrale-marseille.fr-local Subfolders Verbatim Path /home/swytch/.local/share/mail/david.julien@centrale-marseille.fr/ +Inbox /home/swytch/.local/share/mail/david.julien@centrale-marseille.fr/INBOX Channel david.julien@centrale-marseille.fr Expunge Both From dc8c813b361a02b67f0fff8a6670eb873616155e Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 4 Mar 2022 19:17:35 +0100 Subject: [PATCH 04/52] [mail] feat: add various dirs for mailo account --- .config/mutt/accounts/3-david.julien@mailo.com.muttrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.config/mutt/accounts/3-david.julien@mailo.com.muttrc b/.config/mutt/accounts/3-david.julien@mailo.com.muttrc index a7d2f75..e35cd6b 100644 --- a/.config/mutt/accounts/3-david.julien@mailo.com.muttrc +++ b/.config/mutt/accounts/3-david.julien@mailo.com.muttrc @@ -23,7 +23,7 @@ set signature="/home/swytch/.config/mutt/accounts/mailo.signature" unmacro index o macro index o "mailsync" "run mbsync to sync david.julien@mailo.com" -mailboxes "=sent" "=draftbox" "=trash" "=INBOX" "=farigoule" "=promo_fanfare" +mailboxes "=sent" "=draftbox" "=trash" "=INBOX" "=farigoule" "=promo_fanfare" "=mediapart" "=git" "=sosh" set record = "+sent" macro index,pager gs "=sent" "go to sent" macro index,pager Ms ";=sent" "move mail to sent" @@ -47,3 +47,12 @@ macro index,pager Cf ";=farigoule" "copy mail to farigoule" macro index,pager gp "=promo_fanfare" "go to promo_fanfare" macro index,pager Mp ";=promo_fanfare" "move mail to promo_fanfare" macro index,pager Cp ";=promo_fanfare" "copy mail to promo_fanfare" +macro index,pager gm "=mediapart" "go to mediapart" +macro index,pager Mm ";=mediapart" "move mail to mediapart" +macro index,pager Cm ";=mediapart" "copy mail to mediapart" +macro index,pager gg "=git" "go to git" +macro index,pager Mg ";=git" "move mail to git" +macro index,pager Cg ";=git" "copy mail to git" +macro index,pager gh "=sosh" "go to sosh" +macro index,pager Mh ";=sosh" "move mail to sosh" +macro index,pager Ch ";=sosh" "copy mail to sosh" From 888c3399322f420019c1bf8e212ae0aa6d0bb19d Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 4 Mar 2022 19:17:57 +0100 Subject: [PATCH 05/52] [mail] fix: don't autosign mail for centrale account --- .../accounts/4-david.julien@centrale-marseille.fr.muttrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc b/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc index 6529ec5..a4aa0c7 100644 --- a/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc +++ b/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc @@ -9,7 +9,7 @@ set header_cache = /home/swytch/.cache/mutt/david.julien@centrale-marseille.fr/h set message_cachedir = /home/swytch/.cache/mutt/david.julien@centrale-marseille.fr/bodies set mbox_type = Maildir -set crypt_autosign = yes +set crypt_autosign = no set pgp_sign_as = "0x9F46CD164AE1E813" bind index,pager gg noop @@ -23,7 +23,7 @@ set signature="/home/swytch/.config/mutt/accounts/centrale.signature" unmacro index o macro index o "mailsync" "run mbsync to sync david.julien@centrale-marseille.fr" -mailboxes "=Sent" "=Drafts" "=Trash" "=Fanfare" +mailboxes "=Sent" "=Drafts" "=INBOX" "=Trash" "=Fanfare" set record = "+Sent" macro index,pager gs "=Sent" "go to sent" macro index,pager Ms ";=Sent" "move mail to sent" @@ -36,6 +36,10 @@ macro index,pager gt "=Trash" "go to trash" macro index,pager Mt ";=Trash" "move mail to trash" macro index,pager Ct ";=Trash" "copy mail to trash" set trash = "+Trash" +macro index,pager gi "=INBOX" "go to inbox" +macro index,pager Mi ";=INBOX" "move mail to inbox" +macro index,pager Ci ";=INBOX" "copy mail to inbox" +set spoolfile = "+INBOX" macro index,pager gf "=Fanfare" "go to fanfare" macro index,pager Mf ";=Fanfare" "move mail to fanfare" macro index,pager Cf ";=Fanfare" "copy mail to fanfare" From 7cca8731e051cbed8d2d526f184d9eee47eb4209 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 4 Mar 2022 19:18:28 +0100 Subject: [PATCH 06/52] [tmux] fix: lowerleft icon --- .config/tmux/tmux.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index eac9399..9454053 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -10,7 +10,7 @@ set-option -g status-style bg=color0 # bg=bg1, fg=fg1 set-option -g status-left "\ -#[fg=color8, bg=color7]#{?client_prefix,#[bg=color9],} ❐ #S " +#[fg=color8, bg=color7]#{?client_prefix,#[bg=color9],}  #S " set-option -g status-right "\ #[fg=color7, bg=color8] %b. %d \ From e3be31bef9d83c7de690d187e17012a8d1873db1 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sat, 12 Mar 2022 20:38:22 +0100 Subject: [PATCH 07/52] [nvim] fix: no newline after env snippet --- .config/nvim/after/ftplugin/tex.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nvim/after/ftplugin/tex.lua b/.config/nvim/after/ftplugin/tex.lua index 17a28a7..01a07c2 100644 --- a/.config/nvim/after/ftplugin/tex.lua +++ b/.config/nvim/after/ftplugin/tex.lua @@ -87,7 +87,7 @@ ls.snippets = { i(2), t({ "", "\\end{" }), f(copy,1), - t({ "}", "" }), + t({ "}"}), }), s("tikz", { t({ "\\begin{center}" }), From 9f1c5721390307deeb9a8f83645c69bedaa3a721 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 18 Apr 2022 12:17:40 +0200 Subject: [PATCH 08/52] [nvim] fix: path change in sumneko_lua --- .config/nvim/lua/lsp/lua.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.config/nvim/lua/lsp/lua.lua b/.config/nvim/lua/lsp/lua.lua index 7328492..76caeb6 100644 --- a/.config/nvim/lua/lsp/lua.lua +++ b/.config/nvim/lua/lsp/lua.lua @@ -3,13 +3,11 @@ -- License : GPLv3 -- Description : sumneko (lua) config file for lsp -local system_name = "Linux" -- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use local sumneko_root_path = vim.fn.stdpath("data") .. "/lsp_servers/sumneko_lua/extension/server" -local sumneko_binary = sumneko_root_path .. "/bin/" .. system_name .. - "/lua-language-server" +local sumneko_binary = sumneko_root_path .. "/bin/" .. "/lua-language-server" local runtime_path = vim.split(package.path, ';') table.insert(runtime_path, "lua/?.lua") From a38d2a61c5b372ca105057c15a6df1d781abb87c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 18 Apr 2022 12:18:07 +0200 Subject: [PATCH 09/52] [nvim] cleanup: remove unused plugin --- .config/nvim/lua/plugin/packer.lua | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index e966282..1328bc9 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -101,11 +101,4 @@ return require("packer").startup(function() "norcalli/nvim-colorizer.lua", cmd = "ColorizerToggle" } - - -- ens - use { - "whonore/Coqtail", - ft = { "verilog" }, - config = vim.cmd[[let g:coqtail_nomap = 1]] - } end) From f456d9557c2eaa1de98441fdced43e10e7800290 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 18 Apr 2022 12:33:25 +0200 Subject: [PATCH 10/52] [nvim] fix: broken mapping for telescope --- .config/nvim/lua/maps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index 588ddfd..f2d54ec 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -21,7 +21,7 @@ utils.map("n", "lf", "lua vim.lsp.buf.formatting()") -- telescope utils.map("n", "tf", "Telescope find_files") -utils.map("n", "tb", "Telescope file_browser") +utils.map("n", "tb", "Telescope buffers") utils.map("n", "tl", "Telescope live_grep") -- colorscheme From 5e7260104723e4a9f7ad7d25852ee0c406eb0f3c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 18 Apr 2022 12:34:15 +0200 Subject: [PATCH 11/52] [nvim] feat: use f as telescope prefix --- .config/nvim/lua/maps.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index f2d54ec..54c0c79 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -20,9 +20,9 @@ utils.map("n", "lp", "lua vim.diagnostic.goto_prev()") utils.map("n", "lf", "lua vim.lsp.buf.formatting()") -- telescope -utils.map("n", "tf", "Telescope find_files") -utils.map("n", "tb", "Telescope buffers") -utils.map("n", "tl", "Telescope live_grep") +utils.map("n", "ff", "Telescope find_files") +utils.map("n", "fb", "Telescope buffers") +utils.map("n", "fl", "Telescope live_grep") -- colorscheme utils.map("n", "", "lua require(\"astronomy\").toggle_variant()") From ad7f073614e559301e5daa35fb6ce251061ab4c1 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 18 Apr 2022 12:34:42 +0200 Subject: [PATCH 12/52] [nvim] fix: fzf + grep finders for telescope --- .config/nvim/lua/plugin/packer.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 1328bc9..0af119b 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -36,13 +36,13 @@ return require("packer").startup(function() "nvim-telescope/telescope.nvim", opt = true, requires = { - { - "nvim-lua/popup.nvim", - opt = true - }, { "nvim-lua/plenary.nvim", opt = true + }, + {'nvim-telescope/telescope-fzf-native.nvim', + opt = true, + run = 'make' } }, cmd = "Telescope" @@ -70,7 +70,8 @@ return require("packer").startup(function() requires = { { "L3MON4D3/LuaSnip", - config = function() require("plugin.luasnip") end + config = function() + require("plugin.luasnip") end }, "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp", From 4e95af5b7af954a113193472fb7f733f167806a8 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 19:59:21 +0200 Subject: [PATCH 13/52] [dwm] fresh restart: update to 6.3 --- .local/src/dwm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/src/dwm b/.local/src/dwm index f8ad07e..82003c8 160000 --- a/.local/src/dwm +++ b/.local/src/dwm @@ -1 +1 @@ -Subproject commit f8ad07e02878adfbdab1241869630d608566c5c0 +Subproject commit 82003c8dad7b966ab65f339749fb4272eafb8f4b From 98b6a428a7d504d6961943a35e8338fe2ed0fe22 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 20:05:27 +0200 Subject: [PATCH 14/52] [nvim] feat: packer boostrapping on first install --- .config/nvim/lua/plugin/packer.lua | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 0af119b..91a1a3e 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -4,14 +4,19 @@ -- Description : neovim plugins file -local execute = vim.api.nvim_command -local fn = vim.fn - -local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim" - -if fn.empty(fn.glob(install_path)) > 0 then - fn.system({"git", "clone", "https://github.com/wbthomason/packer.nvim", install_path}) - execute "packadd packer.nvim" +local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + print("Cloning packer...") + PACKER_BOOTSTRAP = vim.fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + vim.cmd([[packadd packer.nvim]]) + print("Done.") end return require("packer").startup(function() @@ -102,4 +107,10 @@ return require("packer").startup(function() "norcalli/nvim-colorizer.lua", cmd = "ColorizerToggle" } + + + -- automatically setup the config after cloning + if PACKER_BOOTSTRAP then + require("packer").sync() + end end) From 9c53518d21de4be8e723e6a1ade0278b8c018a47 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 20:06:03 +0200 Subject: [PATCH 15/52] [nvim] cleanup: remove unused Colorizer plugin --- .config/nvim/lua/plugin/packer.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 91a1a3e..1b78c1c 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -100,12 +100,6 @@ return require("packer").startup(function() use { "windwp/nvim-autopairs", config = function() require('nvim-autopairs').setup() end - } - - -- display colors directly in editor - use { - "norcalli/nvim-colorizer.lua", - cmd = "ColorizerToggle" } From b38d33a09bc223c42346265984c8e5d8583f5d54 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 20:06:24 +0200 Subject: [PATCH 16/52] [nvim] feat: local `use` variable for lsp --- .config/nvim/lua/plugin/packer.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 1b78c1c..a223b30 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -19,6 +19,8 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then print("Done.") end +local use = require("packer").use + return require("packer").startup(function() -- packer manages itself use "wbthomason/packer.nvim" From b2c50db8045a15ffb1a8b77b848a0480be7a987f Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 20:07:09 +0200 Subject: [PATCH 17/52] [nvim] feat: Telescope is default --- .config/nvim/lua/plugin/packer.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index a223b30..501008c 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -41,18 +41,14 @@ return require("packer").startup(function() -- fuzzy finder use { "nvim-telescope/telescope.nvim", - opt = true, requires = { { "nvim-lua/plenary.nvim", - opt = true }, {'nvim-telescope/telescope-fzf-native.nvim', - opt = true, run = 'make' } }, - cmd = "Telescope" } -- LSP From 40839ad70b50a77ccf0555e0c4ce8eda48455490 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 20:12:47 +0200 Subject: [PATCH 18/52] [nvim] feat: configure LSPs through lsp-installer !!!BREAK: do not use lsp-config (used under the hood by nvim-lsp-installer) --- .config/nvim/lua/lsp/c.lua | 20 ---- .config/nvim/lua/lsp/init.lua | 5 +- .config/nvim/lua/lsp/lua.lua | 40 -------- .config/nvim/lua/lsp/python.lua | 8 -- .config/nvim/lua/lsp/tex.lua | 13 --- .config/nvim/lua/plugin/lsp_installer.lua | 106 +++++++++++++++++++--- .config/nvim/lua/plugin/packer.lua | 14 +-- 7 files changed, 97 insertions(+), 109 deletions(-) delete mode 100644 .config/nvim/lua/lsp/c.lua delete mode 100644 .config/nvim/lua/lsp/lua.lua delete mode 100644 .config/nvim/lua/lsp/python.lua delete mode 100644 .config/nvim/lua/lsp/tex.lua diff --git a/.config/nvim/lua/lsp/c.lua b/.config/nvim/lua/lsp/c.lua deleted file mode 100644 index 986eca3..0000000 --- a/.config/nvim/lua/lsp/c.lua +++ /dev/null @@ -1,20 +0,0 @@ --- Author : swytch --- Created : Tuesday May 18, 2021 12:08:51 CET --- License : GPLv3 --- Description : clangd config file for lsp - --- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) - - -require("lspconfig").clangd.setup { - cmd = { "clangd", - "--background-index", - "--suggest-missing-includes", - "--clang-tidy", - "--header-insertion=iwyu" - }, - -- The following example advertise capabilities to `clangd`. - capabilities = capabilities, -} diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/lsp/init.lua index 4fbc92a..1cbd609 100644 --- a/.config/nvim/lua/lsp/init.lua +++ b/.config/nvim/lua/lsp/init.lua @@ -66,15 +66,12 @@ M.icons = { Variable = "  ", } + function M.setup() local kinds = vim.lsp.protocol.CompletionItemKind for i, kind in ipairs(kinds) do kinds[i] = M.icons[kind] or kind end - - local ft = vim.bo.filetype - if ft == "cpp" then ft = "c" end - require("lsp." .. ft) -- ./.lua end return M diff --git a/.config/nvim/lua/lsp/lua.lua b/.config/nvim/lua/lsp/lua.lua deleted file mode 100644 index 76caeb6..0000000 --- a/.config/nvim/lua/lsp/lua.lua +++ /dev/null @@ -1,40 +0,0 @@ --- Author : swytch --- Created : Tuesday May 18, 2021 12:08:51 CET --- License : GPLv3 --- Description : sumneko (lua) config file for lsp - - --- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use -local sumneko_root_path = vim.fn.stdpath("data") .. - "/lsp_servers/sumneko_lua/extension/server" -local sumneko_binary = sumneko_root_path .. "/bin/" .. "/lua-language-server" - -local runtime_path = vim.split(package.path, ';') -table.insert(runtime_path, "lua/?.lua") -table.insert(runtime_path, "lua/?/init.lua") - -require'lspconfig'.sumneko_lua.setup { - cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}; - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {"vim", "use", "globals", "utils"}, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, -} diff --git a/.config/nvim/lua/lsp/python.lua b/.config/nvim/lua/lsp/python.lua deleted file mode 100644 index 466a94a..0000000 --- a/.config/nvim/lua/lsp/python.lua +++ /dev/null @@ -1,8 +0,0 @@ --- Author : swytch --- Created : Tuesday May 18, 2021 15:03:43 CET --- License : GPLv3 --- Description : jedi (python) config file for lsp - -require("lspconfig").jedi_language_server.setup{ - cmd = { vim.fn.stdpath("data") .. "/lsp_servers/jedi_language_server/venv/bin/jedi-language-server" } -} diff --git a/.config/nvim/lua/lsp/tex.lua b/.config/nvim/lua/lsp/tex.lua deleted file mode 100644 index a715ed9..0000000 --- a/.config/nvim/lua/lsp/tex.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Author : swytch --- Created : Saturday May 23, 2021 10:34:53 CET --- License : GPLv3 --- Description : LaTeX config file for lsp - -require("lspconfig").texlab.setup { - cmd = { vim.fn.stdpath("data") .. "/lsp_servers/latex/texlab" }, - settings = { - build = { - executable = "pdflatex" - } - } -} diff --git a/.config/nvim/lua/plugin/lsp_installer.lua b/.config/nvim/lua/plugin/lsp_installer.lua index 70e929f..d296e04 100644 --- a/.config/nvim/lua/plugin/lsp_installer.lua +++ b/.config/nvim/lua/plugin/lsp_installer.lua @@ -9,20 +9,18 @@ lsp_installer.settings { ui = { icons = { server_installed = "✓", - server_pending = "➜", - server_uninstalled = "✗" + server_pending = "o", + server_uninstalled = "x" } } } local servers = { - "bashls", - "jedi_language_server", - "texlab", + "clangd", "sumneko_lua", } -for _, name in pairs(servers) do +for _, name in ipairs(servers) do local ok, server = lsp_installer.get_server(name) -- Check that the server is supported in nvim-lsp-installer if ok then @@ -33,15 +31,95 @@ for _, name in pairs(servers) do end end +local lsp_root_path = vim.fn.stdpath("data") .. "/lsp_servers/" +local runtime_path = vim.split(package.path, ';') + + +local clangd_binary = lsp_root_path .. "clangd/clangd/bin/clangd" + +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") + +local enhance_server_opts = { + ["clangd"] = function(opts) + opts.settings = { + cmd = { clangd_binary, + "--background-index", + "--suggest-missing-includes", + "--clang-tidy", + "--header-insertion=iwyu" + }, + } + end, + ["sumneko_lua"] = function(opts) + opts.settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + "vim", + "globals", + "utils" + }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = + vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + } + end, +} + +local on_attach = function(_, bufnr) + local opts = { buffer = bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', + vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', + vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + vim.inspect(vim.lsp.buf.list_workspace_folders()) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'so', + require('telescope.builtin').lsp_document_symbols, opts) + vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {}) +end + +-- nvim-cmp supports additional completion capabilities +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) + lsp_installer.on_server_ready(function(server) - local opts = {} + -- Specify the default options which we'll use to setup all servers + local opts = { + on_attach = on_attach, + capabilities = capabilities, + } - -- (optional) Customize the options passed to the server - -- if server.name == "tsserver" then - -- opts.root_dir = function() ... end - -- end + if enhance_server_opts[server.name] then + -- Enhance the default opts with the server-specific ones + enhance_server_opts[server.name](opts) + end - -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) - server:setup(opts) - vim.cmd [[ do User LspAttachBuffers ]] + server:setup(opts) end) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 501008c..970e546 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -54,17 +54,11 @@ return require("packer").startup(function() -- LSP use { "williamboman/nvim-lsp-installer", - cmd = { - "LspInstall", - "LspInstallInfo" + requires = { + "neovim/nvim-lspconfig", + config = function() require("lsp").setup() end }, - config = function() require("plugin.lsp_installer").setup() end - } - - use { - "neovim/nvim-lspconfig", - ft = { "c", "cpp", "lua", "python", "tex"}, - config = function() require("lsp").setup() end + config = function() require("plugin.lsp_installer") end } -- auto completion From 9ff24a555979fc14c52d9bc2c2bf211aafacae86 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 20:17:26 +0200 Subject: [PATCH 19/52] [nvim] cleanup: move lspconfig.lua to lua/plugin/ --- .config/nvim/lua/{lsp/init.lua => plugin/lsp_config.lua} | 0 .config/nvim/lua/plugin/packer.lua | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename .config/nvim/lua/{lsp/init.lua => plugin/lsp_config.lua} (100%) diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/plugin/lsp_config.lua similarity index 100% rename from .config/nvim/lua/lsp/init.lua rename to .config/nvim/lua/plugin/lsp_config.lua diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 970e546..d866f94 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -56,7 +56,8 @@ return require("packer").startup(function() "williamboman/nvim-lsp-installer", requires = { "neovim/nvim-lspconfig", - config = function() require("lsp").setup() end + config = function() + require("plugin.lsp_config").setup() end }, config = function() require("plugin.lsp_installer") end } From bc67eb8ffe2ca8203bcb73a834231981aff300fe Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 21:30:56 +0200 Subject: [PATCH 20/52] [nvim] feat: update mapping API nvim 0.7 has a dedicated keymap.set function --- .config/nvim/lua/maps.lua | 40 +++++++++++------------ .config/nvim/lua/plugin/lsp_installer.lua | 32 +++++++++--------- .config/nvim/lua/utils.lua | 6 ---- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index 54c0c79..d4bc6d5 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -3,30 +3,30 @@ -- License : GPLv3 -- Description : neovim mappings file -utils.map("n", "", "") -utils.map("n", "y", "\"+y") -utils.map("n", "p", "\"+P") -utils.map("n", "", "w! | !compiler %") -utils.map("n", "u", "PackerSync") -utils.map("n", "c", "ColorizerToggle") +vim.keymap.set({ "n", "v" }, "", "", { silent = true }) +vim.g.mapleader = " " --- LSP -utils.map("n", "gd", "lua vim.lsp.buf.definition()") -utils.map("n", "gD", "lua vim.lsp.buf.declaration()") -utils.map("n", "gr", "lua vim.lsp.buf.references()") -utils.map("n", "gi", "lua vim.lsp.buf.implementation()") -utils.map("n", "ln", "lua vim.diagnostic.goto_next()") -utils.map("n", "lp", "lua vim.diagnostic.goto_prev()") -utils.map("n", "lf", "lua vim.lsp.buf.formatting()") +-- Dealing with word wrap +vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", + { expr = true, silent = true }) +vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", + { expr = true, silent = true }) + +vim.keymap.set("n", "y", "\"+y") +vim.keymap.set("n", "p", "\"+P") +vim.keymap.set("n", "", "w! | !compiler %") +vim.keymap.set("n", "u", function() require("packer").sync() end) -- telescope -utils.map("n", "ff", "Telescope find_files") -utils.map("n", "fb", "Telescope buffers") -utils.map("n", "fl", "Telescope live_grep") +vim.keymap.set("n", "ff", + function() require("telescope.builtin").find_files() end) +vim.keymap.set("n", "fb", + function() require("telescope.builtin").buffers() end) +vim.keymap.set("n", "fl", + function() require("telescope.builtin").live_grep() end) -- colorscheme -utils.map("n", "", "lua require(\"astronomy\").toggle_variant()") +vim.keymap.set("n", "", function() require("astronomy").toggle_variant() end) -- snippets -utils.map("i", "", "luasnip-next-choice", {}) -utils.map("s", "", "luasnip-next-choice", {}) +vim.keymap.set({ "i", "s" }, "", "luasnip-next-choice") diff --git a/.config/nvim/lua/plugin/lsp_installer.lua b/.config/nvim/lua/plugin/lsp_installer.lua index d296e04..45852c6 100644 --- a/.config/nvim/lua/plugin/lsp_installer.lua +++ b/.config/nvim/lua/plugin/lsp_installer.lua @@ -84,25 +84,27 @@ local enhance_server_opts = { local on_attach = function(_, bufnr) local opts = { buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'wa', + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "ln", vim.diagnostic.goto_next, opts) + vim.keymap.set("n", "lp", vim.diagnostic.goto_prev, opts) + vim.keymap.set("n", "lf", vim.lsp.buf.formatting, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set('n', 'wr', + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set('n', 'wl', function() + vim.keymap.set("n", "wl", function() vim.inspect(vim.lsp.buf.list_workspace_folders()) end, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'so', - require('telescope.builtin').lsp_document_symbols, opts) - vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {}) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "so", + require("telescope.builtin").lsp_document_symbols, opts) end -- nvim-cmp supports additional completion capabilities diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua index 34eb80e..9ea50dc 100644 --- a/.config/nvim/lua/utils.lua +++ b/.config/nvim/lua/utils.lua @@ -22,12 +22,6 @@ function M.add_rtp(path) rtp = rtp .. "," .. path end --- map a key with optional options -function M.map(mode, keys, action, options) - options = options or {} - vim.api.nvim_set_keymap(mode, keys, action, options) -end - -- see if a file exists function M.file_exists(file) local f = io.open(file, "rb") From d9e7f76a5fb7e8c860bca0d16e5fc7c335b2f9b0 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 27 Apr 2022 21:58:12 +0200 Subject: [PATCH 21/52] [nvim] format: tabstop=8 -> 4 for lua files --- .config/nvim/after/ftplugin/c.lua | 30 +- .config/nvim/after/ftplugin/lua.lua | 3 +- .config/nvim/after/ftplugin/tex.lua | 185 +++++++------ .config/nvim/lua/colorscheme.lua | 2 +- .config/nvim/lua/globals.lua | 12 +- .config/nvim/lua/maps.lua | 13 +- .config/nvim/lua/plugin/cmp.lua | 132 ++++----- .config/nvim/lua/plugin/lsp_config.lua | 106 ++++---- .config/nvim/lua/plugin/lsp_installer.lua | 144 +++++----- .config/nvim/lua/plugin/packer.lua | 161 +++++------ .config/nvim/lua/plugin/treesitter.lua | 16 +- .config/nvim/lua/settings.lua | 62 ++--- .config/nvim/lua/statusline.lua | 318 +++++++++++----------- 13 files changed, 593 insertions(+), 591 deletions(-) diff --git a/.config/nvim/after/ftplugin/c.lua b/.config/nvim/after/ftplugin/c.lua index ad16ca6..e75fba3 100644 --- a/.config/nvim/after/ftplugin/c.lua +++ b/.config/nvim/after/ftplugin/c.lua @@ -4,10 +4,10 @@ -- Description : c settings file -local opt = vim.opt -local g = vim.g +local opt = vim.opt +local g = vim.g -opt.formatoptions = "trq1jp" +opt.formatoptions = "trq1jp" -- Snippets local ls = require("luasnip") @@ -21,14 +21,14 @@ local f = ls.function_node local copy = utils.copy ls.snippets = { - c = { - s("main", { - t({ "int main(int argc, char* argv[])" }), - t({ "", "{", "\t" }), - i(0), - t({ "", "\treturn 0;"}), - t({ "", "}"}), - }), + c = { + s("main", { + t({ "int main(int argc, char* argv[])" }), + t({ "", "{", "\t" }), + i(0), + t({ "", "\treturn 0;"}), + t({ "", "}"}), + }), s("fn", { -- Simple static text. t("//Parameters: "), @@ -43,9 +43,9 @@ ls.snippets = { i(2, "int foo"), -- Linebreak t({ ")", "{", "\t" }), - i(0), - t({ "", "\treturn 0;"}), - t({ "", "}"}), - }), + i(0), + t({ "", "\treturn 0;"}), + t({ "", "}"}), + }), }, } diff --git a/.config/nvim/after/ftplugin/lua.lua b/.config/nvim/after/ftplugin/lua.lua index 698ac52..ff3633d 100644 --- a/.config/nvim/after/ftplugin/lua.lua +++ b/.config/nvim/after/ftplugin/lua.lua @@ -6,4 +6,5 @@ local opt = vim.opt local g = vim.g -opt.formatoptions = "trq1jp" +opt.formatoptions = "trq1jp" +opt.tabstop = 4 diff --git a/.config/nvim/after/ftplugin/tex.lua b/.config/nvim/after/ftplugin/tex.lua index 01a07c2..71c702f 100644 --- a/.config/nvim/after/ftplugin/tex.lua +++ b/.config/nvim/after/ftplugin/tex.lua @@ -4,11 +4,10 @@ -- Description : tex filetype config -local opt = vim.opt -local g = vim.g +local opt = vim.opt -opt.formatoptions = "trq1jp" -opt.tabstop = 4 +opt.formatoptions = "trq1jp" +opt.tabstop = 4 -- Caps utils.map("i", "AA", "À") @@ -23,15 +22,15 @@ utils.map("i", ":", "\\,:") local ls = require("luasnip") -- some shorthands... -local s = ls.snippet -local sn = ls.snippet_node -local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local c = ls.choice_node -local d = ls.dynamic_node +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node -local copy = utils.copy +local copy = utils.copy -- 'recursive' dynamic snippet. Expands to some text followed by itself. local function rec_ls() @@ -46,85 +45,85 @@ local function rec_ls() end ls.snippets = { - tex = { - -- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many - -- \item as necessary by utilizing a choiceNode. - s("ls", { - t({ "\\begin{itemize}", "\t\\item " }), - i(1), - t({ "" }), - d(2, rec_ls, {}), - t({ "", "\\end{itemize}", "" }), - }), - s("lsl", { - t({ "\\begin{itemize}[label=" }), - i(1), - t( { "]", "\t\\item " }), - i(2), - t({ "" }), - d(3, rec_ls, {}), - t({ "", "\\end{itemize}", "" }), - }), - s("frm", { - t({ "\\begin{" }), - i(1), - t({ "}[" }), - i(2), - t({ "]{" }), - f(copy, 1), - t({ ":" }), - i(3, "foo"), - t({ "}", "\t" }), - i(0), - t({ "", "\\end{" }), - f(copy, 1), - t({ "}", "" }), - }), - s("env", { - t({ "\\begin{" }), - i(1, "foo"), - t({ "}", "\t" }), - i(2), - t({ "", "\\end{" }), - f(copy,1), - t({ "}"}), - }), - s("tikz", { - t({ "\\begin{center}" }), - t({ "", "\t\\begin{tikzpicture}[main/.style = {draw,circle}]", "\t\t" }), - i(1), - t({ "", "\t\\end{tikzpicture}", "\\end{center}" }), - }), - s("ra", { t( "\\rightarrow" )}), - s("Ra", { t("\\Rightarrow" )}), - s("la", { t("\\leftarrow" )}), - s("La", { t("\\Leftarrow" )}), - s("lra", { t("\\leftrightarrow" )}), - s("Lra", { t("\\Leftrightarrow" )}), - s("bb", { - t({ "\\textbf{" }), - i(1), - t({ "}"}), - }), - s("tt", { - t({ "\\texttt{" }), - i(1), - t({ "}"}), - }), - s("ii", { - t({ "\\textit{" }), - i(1), - t({ "}"}), - }), - s("uu", { - t({ "\\underline{" }), - i(1), - t({ "}"}), - }), - s("fsc", { - t({ "\\textsc{" }), - i(1), - t({ "}"}), - }), - }, + tex = { + -- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many + -- \item as necessary by utilizing a choiceNode. + s("ls", { + t({ "\\begin{itemize}", "\t\\item " }), + i(1), + t({ "" }), + d(2, rec_ls, {}), + t({ "", "\\end{itemize}", "" }), + }), + s("lsl", { + t({ "\\begin{itemize}[label=" }), + i(1), + t( { "]", "\t\\item " }), + i(2), + t({ "" }), + d(3, rec_ls, {}), + t({ "", "\\end{itemize}", "" }), + }), + s("frm", { + t({ "\\begin{" }), + i(1), + t({ "}[" }), + i(2), + t({ "]{" }), + f(copy, 1), + t({ ":" }), + i(3, "foo"), + t({ "}", "\t" }), + i(0), + t({ "", "\\end{" }), + f(copy, 1), + t({ "}", "" }), + }), + s("env", { + t({ "\\begin{" }), + i(1, "foo"), + t({ "}", "\t" }), + i(2), + t({ "", "\\end{" }), + f(copy,1), + t({ "}"}), + }), + s("tikz", { + t({ "\\begin{center}" }), + t({ "", "\t\\begin{tikzpicture}[main/.style = {draw,circle}]", "\t\t" }), + i(1), + t({ "", "\t\\end{tikzpicture}", "\\end{center}" }), + }), + s("ra", { t( "\\rightarrow" )}), + s("Ra", { t("\\Rightarrow" )}), + s("la", { t("\\leftarrow" )}), + s("La", { t("\\Leftarrow" )}), + s("lra", { t("\\leftrightarrow" )}), + s("Lra", { t("\\Leftrightarrow" )}), + s("bb", { + t({ "\\textbf{" }), + i(1), + t({ "}"}), + }), + s("tt", { + t({ "\\texttt{" }), + i(1), + t({ "}"}), + }), + s("ii", { + t({ "\\textit{" }), + i(1), + t({ "}"}), + }), + s("uu", { + t({ "\\underline{" }), + i(1), + t({ "}"}), + }), + s("fsc", { + t({ "\\textsc{" }), + i(1), + t({ "}"}), + }), + }, } diff --git a/.config/nvim/lua/colorscheme.lua b/.config/nvim/lua/colorscheme.lua index 83dfddd..bebdd40 100644 --- a/.config/nvim/lua/colorscheme.lua +++ b/.config/nvim/lua/colorscheme.lua @@ -9,5 +9,5 @@ local file = os.getenv("XDG_STATE_HOME") .. "/nvim_colorscheme" local colorscheme = utils.lines_from(file)[0] require("astronomy").setup { - variant = colorscheme, + variant = colorscheme, } diff --git a/.config/nvim/lua/globals.lua b/.config/nvim/lua/globals.lua index 8a77ef8..c19c6c3 100644 --- a/.config/nvim/lua/globals.lua +++ b/.config/nvim/lua/globals.lua @@ -6,13 +6,11 @@ local M = {} -- The module to export M = { - lsp_path = vim.fn.stdpath("data").. "/lsp", - - -- misc - sign_error = "", - sign_warning = "", - sign_hint = "", - sign_info = "", + -- misc + sign_error = "", + sign_warning = "", + sign_hint = "", + sign_info = "", } -- Make it accessible everywhere diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index d4bc6d5..5ee5ec4 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -8,9 +8,9 @@ vim.g.mapleader = " " -- Dealing with word wrap vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", - { expr = true, silent = true }) + { expr = true, silent = true }) vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", - { expr = true, silent = true }) + { expr = true, silent = true }) vim.keymap.set("n", "y", "\"+y") vim.keymap.set("n", "p", "\"+P") @@ -19,14 +19,15 @@ vim.keymap.set("n", "u", function() require("packer").sync() end) -- telescope vim.keymap.set("n", "ff", - function() require("telescope.builtin").find_files() end) + function() require("telescope.builtin").find_files() end) vim.keymap.set("n", "fb", - function() require("telescope.builtin").buffers() end) + function() require("telescope.builtin").buffers() end) vim.keymap.set("n", "fl", - function() require("telescope.builtin").live_grep() end) + function() require("telescope.builtin").live_grep() end) -- colorscheme -vim.keymap.set("n", "", function() require("astronomy").toggle_variant() end) +vim.keymap.set("n", "", + function() require("astronomy").toggle_variant() end) -- snippets vim.keymap.set({ "i", "s" }, "", "luasnip-next-choice") diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index 863282b..5727339 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -8,76 +8,76 @@ local luasnip = require("luasnip") local cmp_autopairs = require('nvim-autopairs.completion.cmp') local check_backspace = function() - 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 + 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 -- If you want insert `(` after select function or method item cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) cmp.setup { - completion = { - autocomplete = false - }, - sources = { - { name = "path" }, - { name = "luasnip" }, - { name = "nvim_lsp" }, - { name = "buffer" }, - { name = "nvim_lua" }, - { name = "calc" }, - { name = "spell" }, - { name = "treesitter" }, - }, - formatting = { - format = function(entry, vim_item) - vim_item.menu = ({ - nvim_lsp = "[lsp]", - nvim_lua = "[nvim]", - luasnip = "[snip]", - path = "[path]", - buffer = "[buff]", - calc = "[calc]", - spell = "[spel]", - treesitter = "[tree]", - })[entry.source.name] - return vim_item - end, - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() 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, { "i", "s" }), - } + completion = { + autocomplete = false + }, + sources = { + { name = "path" }, + { name = "luasnip" }, + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "calc" }, + { name = "spell" }, + { name = "treesitter" }, + }, + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = "[lsp]", + nvim_lua = "[nvim]", + luasnip = "[snip]", + path = "[path]", + buffer = "[buff]", + calc = "[calc]", + spell = "[spel]", + treesitter = "[tree]", + })[entry.source.name] + return vim_item + end, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() 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, { "i", "s" }), + } } diff --git a/.config/nvim/lua/plugin/lsp_config.lua b/.config/nvim/lua/plugin/lsp_config.lua index 1cbd609..fb00539 100644 --- a/.config/nvim/lua/plugin/lsp_config.lua +++ b/.config/nvim/lua/plugin/lsp_config.lua @@ -6,72 +6,72 @@ local M = {} vim.fn.sign_define( - "DiagnosticSignError", - { - texthl = "DiagnosticVirtualTextError", - text = globals.sign_error, - numhl = "DiagnosticSignError" - } + "DiagnosticSignError", + { + texthl = "DiagnosticVirtualTextError", + text = globals.sign_error, + numhl = "DiagnosticSignError" + } ) vim.fn.sign_define( - "DiagnosticSignWarn", - { - texthl = "DiagnosticVirtualTextWarn", - text = globals.sign_warning, - numhl = "DiagnosticSignWarn" - } + "DiagnosticSignWarn", + { + texthl = "DiagnosticVirtualTextWarn", + text = globals.sign_warning, + numhl = "DiagnosticSignWarn" + } ) vim.fn.sign_define( - "DiagnosticSignHint", - { - texthl = "DiagnosticVirtualTextHint", - text = globals.sign_hint, - numhl = "DiagnosticSignHint" - } + "DiagnosticSignHint", + { + texthl = "DiagnosticVirtualTextHint", + text = globals.sign_hint, + numhl = "DiagnosticSignHint" + } ) vim.fn.sign_define( - "DiagnosticSignInfo", - { - texthl = "DiagnosticVirtualTextInfo", - text = globals.sign_info, - numhl = "DiagnosticSignInfo" - } + "DiagnosticSignInfo", + { + texthl = "DiagnosticVirtualTextInfo", + text = globals.sign_info, + numhl = "DiagnosticSignInfo" + } ) M.icons = { - Class = "  ", - Color = "  ", - Constant = " µ ", - Constructor = "  ", - Enum = "  ", - EnumMember = "  ", - Event = "  ", - Field = "  ", - File = "  ", - Folder = "  ", - Function = "  ", - Keyword = "  ", - Interface = "  ", - Method = "  ", - Module = "  ", - Operator = "  ", - Property = "  ", - Reference = "  ", - Snippet = "  ", - Struct = "  ", - Text = "  ", - TypeParameter = "  ", - Unit = "  ", - Value = "  ", - Variable = "  ", + Class = "  ", + Color = "  ", + Constant = " µ ", + Constructor = "  ", + Enum = "  ", + EnumMember = "  ", + Event = "  ", + Field = "  ", + File = "  ", + Folder = "  ", + Function = "  ", + Keyword = "  ", + Interface = "  ", + Method = "  ", + Module = "  ", + Operator = "  ", + Property = "  ", + Reference = "  ", + Snippet = "  ", + Struct = "  ", + Text = "  ", + TypeParameter = "  ", + Unit = "  ", + Value = "  ", + Variable = "  ", } function M.setup() - local kinds = vim.lsp.protocol.CompletionItemKind - for i, kind in ipairs(kinds) do - kinds[i] = M.icons[kind] or kind - end + local kinds = vim.lsp.protocol.CompletionItemKind + for i, kind in ipairs(kinds) do + kinds[i] = M.icons[kind] or kind + end end return M diff --git a/.config/nvim/lua/plugin/lsp_installer.lua b/.config/nvim/lua/plugin/lsp_installer.lua index 45852c6..ab3b51c 100644 --- a/.config/nvim/lua/plugin/lsp_installer.lua +++ b/.config/nvim/lua/plugin/lsp_installer.lua @@ -41,70 +41,72 @@ table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") local enhance_server_opts = { - ["clangd"] = function(opts) - opts.settings = { - cmd = { clangd_binary, - "--background-index", - "--suggest-missing-includes", - "--clang-tidy", - "--header-insertion=iwyu" - }, - } - end, - ["sumneko_lua"] = function(opts) - opts.settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { - "vim", - "globals", - "utils" - }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = - vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - } - end, + ["clangd"] = function(opts) + opts.settings = { + cmd = { clangd_binary, + "--background-index", + "--suggest-missing-includes", + "--clang-tidy", + "--header-insertion=iwyu" + }, + } + end, + ["sumneko_lua"] = function(opts) + opts.settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're + -- using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + "vim", + "globals", + "utils" + }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = + vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but + -- unique identifier + telemetry = { + enable = false, + }, + }, + } + end, } local on_attach = function(_, bufnr) - local opts = { buffer = bufnr } - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) - vim.keymap.set("n", "ln", vim.diagnostic.goto_next, opts) - vim.keymap.set("n", "lp", vim.diagnostic.goto_prev, opts) - vim.keymap.set("n", "lf", vim.lsp.buf.formatting, opts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) - vim.keymap.set("n", "wa", - vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set("n", "wr", - vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set("n", "wl", function() - vim.inspect(vim.lsp.buf.list_workspace_folders()) - end, opts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) - vim.keymap.set("n", "so", - require("telescope.builtin").lsp_document_symbols, opts) + local opts = { buffer = bufnr } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "ln", vim.diagnostic.goto_next, opts) + vim.keymap.set("n", "lp", vim.diagnostic.goto_prev, opts) + vim.keymap.set("n", "lf", vim.lsp.buf.formatting, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "wa", + vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "wr", + vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set("n", "wl", function() + vim.inspect(vim.lsp.buf.list_workspace_folders()) + end, opts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "so", + require("telescope.builtin").lsp_document_symbols, opts) end -- nvim-cmp supports additional completion capabilities @@ -112,16 +114,16 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) lsp_installer.on_server_ready(function(server) - -- Specify the default options which we'll use to setup all servers - local opts = { - on_attach = on_attach, - capabilities = capabilities, - } + -- Specify the default options which we'll use to setup all servers + local opts = { + on_attach = on_attach, + capabilities = capabilities, + } - if enhance_server_opts[server.name] then - -- Enhance the default opts with the server-specific ones - enhance_server_opts[server.name](opts) - end + if enhance_server_opts[server.name] then + -- Enhance the default opts with the server-specific ones + enhance_server_opts[server.name](opts) + end - server:setup(opts) + server:setup(opts) end) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index d866f94..dddeee8 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -6,98 +6,99 @@ local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - print("Cloning packer...") - PACKER_BOOTSTRAP = vim.fn.system({ - "git", - "clone", - "--depth", - "1", - "https://github.com/wbthomason/packer.nvim", - install_path, - }) - vim.cmd([[packadd packer.nvim]]) - print("Done.") + print("Cloning packer...") + PACKER_BOOTSTRAP = vim.fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + vim.cmd([[packadd packer.nvim]]) + print("Done.") end local use = require("packer").use return require("packer").startup(function() - -- packer manages itself - use "wbthomason/packer.nvim" + -- packer manages itself + use "wbthomason/packer.nvim" - -- colorscheme - use { - "~/.local/src/astronomy.nvim", - config = function() require("colorscheme") end - } + -- colorscheme + use { + "~/.local/src/astronomy.nvim", + config = function() require("colorscheme") end + } - -- tree-sitter - use { - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - config = function() require("plugin.treesitter") end - } + -- tree-sitter + use { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + config = function() require("plugin.treesitter") end + } - -- fuzzy finder - use { - "nvim-telescope/telescope.nvim", - requires = { - { - "nvim-lua/plenary.nvim", - }, - {'nvim-telescope/telescope-fzf-native.nvim', - run = 'make' - } - }, - } + -- fuzzy finder + use { + "nvim-telescope/telescope.nvim", + requires = { + { + "nvim-lua/plenary.nvim", + }, + { + "nvim-telescope/telescope-fzf-native.nvim", + run = "make" + } + }, + } - -- LSP - use { - "williamboman/nvim-lsp-installer", - requires = { - "neovim/nvim-lspconfig", - config = function() - require("plugin.lsp_config").setup() end - }, - config = function() require("plugin.lsp_installer") end - } + -- LSP + use { + "williamboman/nvim-lsp-installer", + requires = { + "neovim/nvim-lspconfig", + config = function() + require("plugin.lsp_config").setup() end + }, + config = function() require("plugin.lsp_installer") end + } - -- auto completion - use { - "hrsh7th/nvim-cmp", - requires = { - { - "L3MON4D3/LuaSnip", - config = function() - require("plugin.luasnip") end - }, - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-calc", - "ray-x/cmp-treesitter", - "f3fora/cmp-spell", - }, - config = function() require("plugin.cmp") end - } + -- auto completion + use { + "hrsh7th/nvim-cmp", + requires = { + { + "L3MON4D3/LuaSnip", + config = function() + require("plugin.luasnip") end + }, + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-calc", + "ray-x/cmp-treesitter", + "f3fora/cmp-spell", + }, + config = function() require("plugin.cmp") end + } - -- commenting, simplified - use { - "numToStr/Comment.nvim", - config = function() require("plugin.comment") end - } + -- commenting, simplified + use { + "numToStr/Comment.nvim", + config = function() require("plugin.comment") end + } - -- autopairs - use { - "windwp/nvim-autopairs", - config = function() require('nvim-autopairs').setup() end - } + -- autopairs + use { + "windwp/nvim-autopairs", + config = function() require("nvim-autopairs").setup() end + } - -- automatically setup the config after cloning - if PACKER_BOOTSTRAP then - require("packer").sync() - end + -- automatically setup the config after cloning + if PACKER_BOOTSTRAP then + require("packer").sync() + end end) diff --git a/.config/nvim/lua/plugin/treesitter.lua b/.config/nvim/lua/plugin/treesitter.lua index e294959..0f70eb9 100644 --- a/.config/nvim/lua/plugin/treesitter.lua +++ b/.config/nvim/lua/plugin/treesitter.lua @@ -4,12 +4,12 @@ -- Description : treesitter config file require("nvim-treesitter.configs").setup { - ensure_installed = { "c", "lua", "python", "bash" }, - ignore_install = { "javascript" }, - highlight = { - enable = true, - }, - indent = { - enable = true, - }, + ensure_installed = { "c", "lua", "python", "bash" }, + ignore_install = { "javascript" }, + highlight = { + enable = true, + }, + indent = { + enable = true, + }, } diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 08d21e9..b7fd6c1 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -7,7 +7,7 @@ local opt = vim.opt local g = vim.g -- general -opt.wildignore = { +opt.wildignore = { ".git", "*.o", "*.class", "*.jpg", "*.jpeg", "*.png", @@ -18,41 +18,41 @@ opt.wildmode = { "longest", "full" } opt.wildoptions = "pum" -- editor -opt.lazyredraw = true -opt.splitright = true -opt.splitbelow = true -opt.scrolloff = 4 -opt.termguicolors = true -opt.background = "dark" -opt.cursorline = true -opt.shortmess = opt.shortmess:append { c = true } -opt.number = true -opt.relativenumber = true -opt.signcolumn = "yes" -opt.listchars = { - tab = "<->", - nbsp = "␣", - trail = "·", - extends = ">", - precedes = "<", +opt.lazyredraw = true +opt.splitright = true +opt.splitbelow = true +opt.scrolloff = 4 +opt.termguicolors = true +opt.background = "dark" +opt.cursorline = true +opt.shortmess = opt.shortmess:append { c = true } +opt.number = true +opt.relativenumber = true +opt.signcolumn = "yes" +opt.listchars = { + tab = "<->", + nbsp = "␣", + trail = "·", + extends = ">", + precedes = "<", } -opt.showmatch = true -opt.ignorecase = true -opt.smartcase = true -opt.inccommand = "split" -opt.completeopt = { "menuone", "noselect" } +opt.showmatch = true +opt.ignorecase = true +opt.smartcase = true +opt.inccommand = "split" +opt.completeopt = { "menuone", "noselect" } -- statusline -opt.laststatus = 2 -opt.showmode = false +opt.laststatus = 2 +opt.showmode = false -- text, tabs, indents -opt.textwidth = 79 -opt.shiftwidth = 8 -opt.softtabstop = -1 -opt.expandtab = true -opt.shiftwidth = 0 -opt.backspace = { "indent", "eol", "start" } +opt.textwidth = 79 +opt.shiftwidth = 8 +opt.softtabstop = -1 +opt.expandtab = true +opt.shiftwidth = 0 +opt.backspace = { "indent", "eol", "start" } -- augroups utils.create_augroup({ diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua index 65e2f4d..88d438a 100644 --- a/.config/nvim/lua/statusline.lua +++ b/.config/nvim/lua/statusline.lua @@ -6,204 +6,204 @@ local function gen_section(hl_string, items) - local out = "" - for _, item in pairs(items) do - if item ~= "" then - out = out .. " " .. item - end - end - if out ~="" then - return hl_string .. out .. " " - else - return out + local out = "" + for _, item in pairs(items) do + if item ~= "" then + out = out .. " " .. item end + end + if out ~="" then + return hl_string .. out .. " " + else + return out + end end -- sensible names for vim modes local function get_mode(m) - local mode_group = { - ["n"] = "Normal", - ["no"] = "O-Pending", - ["nov"] = "O-Pending", - ["noV"] = "O-Pending", - ["no"] = "O-Pending", - ["niI"] = "Normal", - ["niR"] = "Normal", - ["niV"] = "Normal", - ["v"] = "Visual", - ["V"] = "V-Line", - [""] = "V-Block", - ["s"] = "Select", - ["S"] = "S-Line", - [""] = "S-Block", - ["i"] = "Insert", - ["ic"] = "Insert", - ["ix"] = "Insert", - ["R"] = "Replace", - ["Rc"] = "Replace", - ["Rv"] = "V-Replace", - ["Rx"] = "Replace", - ["c"] = "Command", - ["cv"] = "Ex", - ["ce"] = "Ex", - ["r"] = "Prompt", - ["rm"] = "Prompt", - ["r?"] = "Prompt", - ["!"] = "Shell", - ["t"] = "Terminal", - } - return mode_group[m] or "None" + local mode_group = { + ["n"] = "Normal", + ["no"] = "O-Pending", + ["nov"] = "O-Pending", + ["noV"] = "O-Pending", + ["no"] = "O-Pending", + ["niI"] = "Normal", + ["niR"] = "Normal", + ["niV"] = "Normal", + ["v"] = "Visual", + ["V"] = "V-Line", + [""] = "V-Block", + ["s"] = "Select", + ["S"] = "S-Line", + [""] = "S-Block", + ["i"] = "Insert", + ["ic"] = "Insert", + ["ix"] = "Insert", + ["R"] = "Replace", + ["Rc"] = "Replace", + ["Rv"] = "V-Replace", + ["Rx"] = "Replace", + ["c"] = "Command", + ["cv"] = "Ex", + ["ce"] = "Ex", + ["r"] = "Prompt", + ["rm"] = "Prompt", + ["r?"] = "Prompt", + ["!"] = "Shell", + ["t"] = "Terminal", + } + return mode_group[m] or "None" end local function get_mode_display_name(m) - local mode = { - ["Normal"] = "[ NRM ]", - ["O-Pending"] = "[ OTR ]", - ["Visual"] = "[ VSL ]", - ["V-Line"] = "[ V·L ]", - ["V-Block"] = "[ V·B ]", - ["Select"] = "[ SEL ]", - ["S-Line"] = "[ S·L ]", - ["S-Block"] = "[ S·B ]", - ["Insert"] = "[ INS ]", - ["Replace"] = "[ RPL ]", - ["Command"] = "[ CMD ]", - ["Prompt"] = "[ PMT ]", - ["Shell"] = "[ SHL ]", - ["Terminal"] = "[ TRM ]", - ["None"] = "[ --- ]" - } - return mode[m] + local mode = { + ["Normal"] = "[ NRM ]", + ["O-Pending"] = "[ OTR ]", + ["Visual"] = "[ VSL ]", + ["V-Line"] = "[ V·L ]", + ["V-Block"] = "[ V·B ]", + ["Select"] = "[ SEL ]", + ["S-Line"] = "[ S·L ]", + ["S-Block"] = "[ S·B ]", + ["Insert"] = "[ INS ]", + ["Replace"] = "[ RPL ]", + ["Command"] = "[ CMD ]", + ["Prompt"] = "[ PMT ]", + ["Shell"] = "[ SHL ]", + ["Terminal"] = "[ TRM ]", + ["None"] = "[ --- ]" + } + return mode[m] end -- get the highlight group for a mode group local function get_mode_color(m) - local color = { - ["Normal"] = "%#NormalMode#", - ["O-Pending"] = "%#NormalMode#", - ["Visual"] = "%#VisualMode#", - ["V-Line"] = "%#VisualMode#", - ["V-Block"] = "%#VisualMode#", - ["Select"] = "%#NormalMode#", - ["S-Line"] = "%#NormalMode#", - ["S-Block"] = "%#NormalMode#", - ["Insert"] = "%#InsertMode#", - ["Replace"] = "%#ReplaceMode#", - ["Command"] = "%#CommandMode#", - ["Prompt"] = "%#NormalMode#", - ["Shell"] = "%#NormalMode#", - ["Terminal"] = "%#NormalMode#", - ["None"] = "%#NormalMode#" - } - return color[m] + local color = { + ["Normal"] = "%#NormalMode#", + ["O-Pending"] = "%#NormalMode#", + ["Visual"] = "%#VisualMode#", + ["V-Line"] = "%#VisualMode#", + ["V-Block"] = "%#VisualMode#", + ["Select"] = "%#NormalMode#", + ["S-Line"] = "%#NormalMode#", + ["S-Block"] = "%#NormalMode#", + ["Insert"] = "%#InsertMode#", + ["Replace"] = "%#ReplaceMode#", + ["Command"] = "%#CommandMode#", + ["Prompt"] = "%#NormalMode#", + ["Shell"] = "%#NormalMode#", + ["Terminal"] = "%#NormalMode#", + ["None"] = "%#NormalMode#" + } + return color[m] end -- from https://github.com/nvim-lua/lsp-status.nvim/blob/master/lua/lsp-status/diagnostics.lua local function get_lsp_diagnostics(bufnr) - local result = {} - local levels = { - errors = "Error", - warnings = "Warn", - info = "Info", - hints = "Hint" - } + local result = {} + local levels = { + errors = "Error", + warnings = "Warn", + info = "Info", + hints = "Hint" + } - for k, level in pairs(levels) do - local count = 0 - local diags = vim.diagnostic.get(bufnr, { severity = level }) - for _, _ in pairs(diags) do - count = count + 1 - end - result[k] = count + for k, level in pairs(levels) do + local count = 0 + local diags = vim.diagnostic.get(bufnr, { severity = level }) + for _, _ in pairs(diags) do + count = count + 1 end + result[k] = count + end - return result + return result end local function process_diagnostics(prefix, n, hl) - if n > 0 then - return hl .. prefix .. n - else - return "" - end +if n > 0 then + return hl .. prefix .. n +else + return "" +end end local function spell_check() - if vim.wo.spell then - local lang = vim.o.spelllang - return "[SPELL=" .. lang .. "]" - else - return "" - end +if vim.wo.spell then + local lang = vim.o.spelllang + return "[SPELL=" .. lang .. "]" +else + return "" +end end local function statusline_focused() - local diagnostics = get_lsp_diagnostics() - local mode = vim.fn.mode() - local mg = get_mode(mode) - local accent_color = get_mode_color(mg) +local diagnostics = get_lsp_diagnostics() +local mode = vim.fn.mode() +local mg = get_mode(mode) +local accent_color = get_mode_color(mg) - local left = table.concat { - gen_section(accent_color, {get_mode_display_name(mg)}), - gen_section("%#Middle#", {"%f"}), - gen_section("%#Bottom#", {"%m", "%r"}), - gen_section( - "%#Alert#", - { - process_diagnostics( - globals.sign_error .. " ", - diagnostics.errors, - "%#DiagnosticVirtualTextError#" - ), - process_diagnostics( - globals.sign_warning .. " ", - diagnostics.warnings, - "%#DiagnosticVirtualTextWarn#" - ), - process_diagnostics( - globals.sign_info .. " ", - diagnostics.info, - "%#DiagnosticVirtualTextInfo#" - ) - } - ) +local left = table.concat { + gen_section(accent_color, {get_mode_display_name(mg)}), + gen_section("%#Middle#", {"%f"}), + gen_section("%#Bottom#", {"%m", "%r"}), + gen_section( + "%#Alert#", + { + process_diagnostics( + globals.sign_error .. " ", + diagnostics.errors, + "%#DiagnosticVirtualTextError#" + ), + process_diagnostics( + globals.sign_warning .. " ", + diagnostics.warnings, + "%#DiagnosticVirtualTextWarn#" + ), + process_diagnostics( + globals.sign_info .. " ", + diagnostics.info, + "%#DiagnosticVirtualTextInfo#" + ) } - local right = table.concat { - gen_section( - "%#Bottom#", - { - spell_check(), - vim.bo.filetype - } - ), - gen_section("%#Middle#", {"%03.p%%"}), - gen_section("%#Top#", {"-%03.c-"}) + ) +} +local right = table.concat { + gen_section( + "%#Bottom#", + { + spell_check(), + vim.bo.filetype } + ), + gen_section("%#Middle#", {"%03.p%%"}), + gen_section("%#Top#", {"-%03.c-"}) +} - return table.concat { - left, - "%#Statusline#", - "%=", - right - } +return table.concat { + left, + "%#Statusline#", + "%=", + right +} end local function statusline_not_focused() - return table.concat { - gen_section("%#StatuslineNF#", {"%f", "%m"}), - "%=", - gen_section("%#StatuslineNF#", {"%03.p%%"}), - gen_section("%#StatuslineNF#", {"-%03.c-"}) - } + return table.concat { + gen_section("%#StatuslineNF#", {"%f", "%m"}), + "%=", + gen_section("%#StatuslineNF#", {"%03.p%%"}), + gen_section("%#StatuslineNF#", {"-%03.c-"}) + } end function _G.gen_statusline() - if vim.g.statusline_winid == vim.fn.win_getid() then - return statusline_focused() - else - return statusline_not_focused() - end + if vim.g.statusline_winid == vim.fn.win_getid() then + return statusline_focused() + else + return statusline_not_focused() + end end vim.o.statusline = "%!luaeval(\"gen_statusline()\")" From 4669337540d05aad2f920a99aa9c1ee661f7a7e6 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 29 Apr 2022 00:18:25 +0200 Subject: [PATCH 22/52] [nvim] rewrite: has_words_before in cmp.lua --- .config/nvim/lua/plugin/cmp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index 5727339..bc4b60a 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -7,7 +7,7 @@ local cmp = require("cmp") local luasnip = require("luasnip") local cmp_autopairs = require('nvim-autopairs.completion.cmp') -local check_backspace = function() +local has_words_before = function() 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]: @@ -64,7 +64,7 @@ cmp.setup { cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() - elseif check_backspace() then + elseif has_words_before() then cmp.complete() else fallback() From 6581d9af42e899a7800d80c9893187f221e3561b Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 29 Apr 2022 00:18:53 +0200 Subject: [PATCH 23/52] [nvim] feat: only jump inside the snippet --- .config/nvim/lua/plugin/cmp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index bc4b60a..92e29b2 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -62,7 +62,7 @@ cmp.setup { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then + elseif luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() elseif has_words_before() then cmp.complete() From 6fd5067bc499467aaf3c953e2e88aacb8852f744 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 29 Apr 2022 00:20:18 +0200 Subject: [PATCH 24/52] [nvim] fix: snippets config --- .config/nvim/after/ftplugin/c.lua | 52 +-- .config/nvim/after/ftplugin/tex.lua | 162 ++++----- .config/nvim/lua/plugin/luasnip.lua | 521 ++++++++++++++-------------- 3 files changed, 367 insertions(+), 368 deletions(-) diff --git a/.config/nvim/after/ftplugin/c.lua b/.config/nvim/after/ftplugin/c.lua index e75fba3..b42e1a6 100644 --- a/.config/nvim/after/ftplugin/c.lua +++ b/.config/nvim/after/ftplugin/c.lua @@ -20,32 +20,32 @@ local f = ls.function_node local copy = utils.copy -ls.snippets = { - c = { - s("main", { - t({ "int main(int argc, char* argv[])" }), - t({ "", "{", "\t" }), +ls.add_snippets( "c", { + s("main", { + t({ "int main(int argc, char* argv[])" }), + t({ "", "{", "\t" }), + i(0), + t({ "", "\treturn 0;"}), + t({ "", "}"}), + }), + s("fn", { + -- Simple static text. + t("//Parameters: "), + -- function, first parameter is the function, second the Placeholders + -- whose text it gets as input. + f(copy, 2), + t({ "", "" }), + -- Placeholder/Insert. + i(1), + t("("), + -- Placeholder with initial text. + i(2, "int foo"), + -- Linebreak + t({ ")", "{", "\t" }), i(0), t({ "", "\treturn 0;"}), t({ "", "}"}), - }), - s("fn", { - -- Simple static text. - t("//Parameters: "), - -- function, first parameter is the function, second the Placeholders - -- whose text it gets as input. - f(copy, 2), - t({ "", "" }), - -- Placeholder/Insert. - i(1), - t("("), - -- Placeholder with initial text. - i(2, "int foo"), - -- Linebreak - t({ ")", "{", "\t" }), - i(0), - t({ "", "\treturn 0;"}), - t({ "", "}"}), - }), - }, -} + }), +}, { + key = "c" + }) diff --git a/.config/nvim/after/ftplugin/tex.lua b/.config/nvim/after/ftplugin/tex.lua index 71c702f..8ec747a 100644 --- a/.config/nvim/after/ftplugin/tex.lua +++ b/.config/nvim/after/ftplugin/tex.lua @@ -44,86 +44,86 @@ local function rec_ls() ) end -ls.snippets = { - tex = { - -- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many - -- \item as necessary by utilizing a choiceNode. - s("ls", { - t({ "\\begin{itemize}", "\t\\item " }), - i(1), - t({ "" }), - d(2, rec_ls, {}), - t({ "", "\\end{itemize}", "" }), - }), - s("lsl", { - t({ "\\begin{itemize}[label=" }), - i(1), - t( { "]", "\t\\item " }), - i(2), - t({ "" }), - d(3, rec_ls, {}), - t({ "", "\\end{itemize}", "" }), - }), - s("frm", { - t({ "\\begin{" }), - i(1), - t({ "}[" }), - i(2), - t({ "]{" }), - f(copy, 1), - t({ ":" }), - i(3, "foo"), - t({ "}", "\t" }), - i(0), - t({ "", "\\end{" }), - f(copy, 1), - t({ "}", "" }), - }), - s("env", { - t({ "\\begin{" }), - i(1, "foo"), - t({ "}", "\t" }), - i(2), - t({ "", "\\end{" }), - f(copy,1), - t({ "}"}), - }), - s("tikz", { - t({ "\\begin{center}" }), - t({ "", "\t\\begin{tikzpicture}[main/.style = {draw,circle}]", "\t\t" }), - i(1), - t({ "", "\t\\end{tikzpicture}", "\\end{center}" }), - }), - s("ra", { t( "\\rightarrow" )}), - s("Ra", { t("\\Rightarrow" )}), - s("la", { t("\\leftarrow" )}), - s("La", { t("\\Leftarrow" )}), - s("lra", { t("\\leftrightarrow" )}), - s("Lra", { t("\\Leftrightarrow" )}), - s("bb", { - t({ "\\textbf{" }), - i(1), - t({ "}"}), - }), - s("tt", { - t({ "\\texttt{" }), +ls.add_snippets("tex", { + -- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many + -- \item as necessary by utilizing a choiceNode. + s("ls", { + t({ "\\begin{itemize}", "\t\\item " }), + i(1), + t({ "" }), + d(2, rec_ls, {}), + t({ "", "\\end{itemize}", "" }), + }), + s("lsl", { + t({ "\\begin{itemize}[label=" }), + i(1), + t( { "]", "\t\\item " }), + i(2), + t({ "" }), + d(3, rec_ls, {}), + t({ "", "\\end{itemize}", "" }), + }), + s("frm", { + t({ "\\begin{" }), + i(1), + t({ "}[" }), + i(2), + t({ "]{" }), + f(copy, 1), + t({ ":" }), + i(3, "foo"), + t({ "}", "\t" }), + i(0), + t({ "", "\\end{" }), + f(copy, 1), + t({ "}", "" }), + }), + s("env", { + t({ "\\begin{" }), + i(1, "foo"), + t({ "}", "\t" }), + i(2), + t({ "", "\\end{" }), + f(copy,1), + t({ "}"}), + }), + s("tikz", { + t({ "\\begin{center}" }), + t({ "", "\t\\begin{tikzpicture}[main/.style = {draw,circle}]", "\t\t" }), + i(1), + t({ "", "\t\\end{tikzpicture}", "\\end{center}" }), + }), + s("ra", { t( "\\rightarrow" )}), + s("Ra", { t("\\Rightarrow" )}), + s("la", { t("\\leftarrow" )}), + s("La", { t("\\Leftarrow" )}), + s("lra", { t("\\leftrightarrow" )}), + s("Lra", { t("\\Leftrightarrow" )}), + s("bb", { + t({ "\\textbf{" }), i(1), t({ "}"}), - }), - s("ii", { - t({ "\\textit{" }), - i(1), - t({ "}"}), - }), - s("uu", { - t({ "\\underline{" }), - i(1), - t({ "}"}), - }), - s("fsc", { - t({ "\\textsc{" }), - i(1), - t({ "}"}), - }), - }, -} + }), + s("tt", { + t({ "\\texttt{" }), + i(1), + t({ "}"}), + }), + s("ii", { + t({ "\\textit{" }), + i(1), + t({ "}"}), + }), + s("uu", { + t({ "\\underline{" }), + i(1), + t({ "}"}), + }), + s("fsc", { + t({ "\\textsc{" }), + i(1), + t({ "}"}), + }), +}, { + key = "tex" +}) diff --git a/.config/nvim/lua/plugin/luasnip.lua b/.config/nvim/lua/plugin/luasnip.lua index 07650c3..b88b007 100644 --- a/.config/nvim/lua/plugin/luasnip.lua +++ b/.config/nvim/lua/plugin/luasnip.lua @@ -59,270 +59,269 @@ local function date_input(fmt) return sn(nil, i(1, os.date(fmt))) end -ls.snippets = { - -- When trying to expand a snippet, luasnip first searches the tables for - -- each filetype specified in 'filetype' followed by 'all'. - -- If ie. the filetype is 'lua.c' - -- - luasnip.lua - -- - luasnip.c - -- - luasnip.all - -- are searched in that order. - all = { +-- snippets are added via ls.add_snippets(filetype, snippets[, opts]), where +-- opts may specify the `type` of the snippets ("snippets" or "autosnippets", +-- for snippets that should expand directly after the trigger is typed). +-- +-- opts can also specify a key. By passing an unique key to each add_snippets, it's possible to reload snippets by +-- re-`:luafile`ing the file in which they are defined (eg. this one). +ls.add_snippets( "all", { -- trigger is fn. - s("fn", { - -- Simple static text. - t("//Parameters: "), - -- function, first parameter is the function, second the Placeholders - -- whose text it gets as input. - f(copy, 2), - t({ "", "function " }), - -- Placeholder/Insert. - i(1), - t("("), - -- Placeholder with initial text. - i(2, "int foo"), - -- Linebreak - t({ ") {", "\t" }), - -- Last Placeholder, exit Point of the snippet. EVERY 'outer' SNIPPET NEEDS Placeholder 0. - i(0), - t({ "", "}" }), - }), - s("class", { - -- Choice: Switch between two different Nodes, first parameter is its position, second a list of nodes. - c(1, { - t("public "), - t("private "), - }), - t("class "), - i(2), - t(" "), - c(3, { - t("{"), - -- sn: Nested Snippet. Instead of a trigger, it has a position, just like insert-nodes. !!! These don't expect a 0-node!!!! - -- Inside Choices, Nodes don't need a position as the choice node is the one being jumped to. - sn(nil, { - t("extends "), - i(1), - t(" {"), - }), - sn(nil, { - t("implements "), - i(1), - t(" {"), - }), - }), - t({ "", "\t" }), - i(0), - t({ "", "}" }), - }), - -- Use a dynamic_node to interpolate the output of a - -- function (see date_input above) into the initial - -- value of an insert_node. - s("novel", { - t("It was a dark and stormy night on "), - d(1, date_input, {}, "%A, %B %d of %Y"), - t(" and the clocks were striking thirteen."), - }), - -- Parsing snippets: First parameter: Snippet-Trigger, Second: Snippet body. - -- Placeholders are parsed into choices with 1. the placeholder text(as a snippet) and 2. an empty string. - -- This means they are not SELECTed like in other editors/Snippet engines. - ls.parser.parse_snippet( - "lspsyn", - "Wow! This ${1:Stuff} really ${2:works. ${3:Well, a bit.}}" - ), + s("fn", { + -- Simple static text. + t("//Parameters: "), + -- function, first parameter is the function, second the Placeholders + -- whose text it gets as input. + f(copy, 2), + t({ "", "function " }), + -- Placeholder/Insert. + i(1), + t("("), + -- Placeholder with initial text. + i(2, "int foo"), + -- Linebreak + t({ ") {", "\t" }), + -- Last Placeholder, exit Point of the snippet. EVERY 'outer' SNIPPET NEEDS Placeholder 0. + i(0), + t({ "", "}" }), + }), + s("class", { + -- Choice: Switch between two different Nodes, first parameter is its position, second a list of nodes. + c(1, { + t("public "), + t("private "), + }), + t("class "), + i(2), + t(" "), + c(3, { + t("{"), + -- sn: Nested Snippet. Instead of a trigger, it has a position, just like insert-nodes. !!! These don't expect a 0-node!!!! + -- Inside Choices, Nodes don't need a position as the choice node is the one being jumped to. + sn(nil, { + t("extends "), + i(1), + t(" {"), + }), + sn(nil, { + t("implements "), + i(1), + t(" {"), + }), + }), + t({ "", "\t" }), + i(0), + t({ "", "}" }), + }), + -- Use a dynamic_node to interpolate the output of a + -- function (see date_input above) into the initial + -- value of an insert_node. + s("novel", { + t("It was a dark and stormy night on "), + d(1, date_input, {}, "%A, %B %d of %Y"), + t(" and the clocks were striking thirteen."), + }), + -- Parsing snippets: First parameter: Snippet-Trigger, Second: Snippet body. + -- Placeholders are parsed into choices with 1. the placeholder text(as a snippet) and 2. an empty string. + -- This means they are not SELECTed like in other editors/Snippet engines. + ls.parser.parse_snippet( + "lspsyn", + "Wow! This ${1:Stuff} really ${2:works. ${3:Well, a bit.}}" + ), - -- When wordTrig is set to false, snippets may also expand inside other words. - ls.parser.parse_snippet( - { trig = "te", wordTrig = false }, - "${1:cond} ? ${2:true} : ${3:false}" - ), + -- When wordTrig is set to false, snippets may also expand inside other words. + ls.parser.parse_snippet( + { trig = "te", wordTrig = false }, + "${1:cond} ? ${2:true} : ${3:false}" + ), - -- When regTrig is set, trig is treated like a pattern, this snippet will expand after any number. - ls.parser.parse_snippet({ trig = "%d", regTrig = true }, "A Number!!"), - -- Using the condition, it's possible to allow expansion only in specific cases. - s("cond", { - t("will only expand in c-style comments"), - }, { - condition = function(line_to_cursor, matched_trigger, captures) - -- optional whitespace followed by // - return line_to_cursor:match("%s*//") - end, - }), - -- there's some built-in conditions in "luasnip.extras.expand_conditions". - s("cond2", { - t("will only expand at the beginning of the line"), - }, { - condition = conds.line_begin, - }), - -- The last entry of args passed to the user-function is the surrounding snippet. - s( - { trig = "a%d", regTrig = true }, - f(function(_, snip) - return "Triggered with " .. snip.trigger .. "." - end, {}) - ), - -- It's possible to use capture-groups inside regex-triggers. - s( - { trig = "b(%d)", regTrig = true }, - f(function(_, snip) - return "Captured Text: " .. snip.captures[1] .. "." - end, {}) - ), - s({ trig = "c(%d+)", regTrig = true }, { - t("will only expand for even numbers"), - }, { - condition = function(line_to_cursor, matched_trigger, captures) - return tonumber(captures[1]) % 2 == 0 - end, - }), - -- Use a function to execute any shell command and print its text. - s("bash", f(bash, {}, "ls")), - -- Short version for applying String transformations using function nodes. - s("transform", { - i(1, "initial text"), - t({ "", "" }), - -- lambda nodes accept an l._1,2,3,4,5, which in turn accept any string transformations. - -- This list will be applied in order to the first node given in the second argument. - l(l._1:match("[^i]*$"):gsub("i", "o"):gsub(" ", "_"):upper(), 1), - }), - s("transform2", { - i(1, "initial text"), - t("::"), - i(2, "replacement for e"), - t({ "", "" }), - -- Lambdas can also apply transforms USING the text of other nodes: - l(l._1:gsub("e", l._2), { 1, 2 }), - }), - s({ trig = "trafo(%d+)", regTrig = true }, { - -- env-variables and captures can also be used: - l(l.CAPTURE1:gsub("1", l.TM_FILENAME), {}), - }), - -- Set store_selection_keys = "" (for example) in your - -- luasnip.config.setup() call to access TM_SELECTED_TEXT. In - -- this case, select a URL, hit Tab, then expand this snippet. - s("link_url", { - t(''), - i(1), - t(""), - i(0), - }), - -- Shorthand for repeating the text in a given node. - s("repeat", { i(1, "text"), t({ "", "" }), r(1) }), - -- Directly insert the ouput from a function evaluated at runtime. - s("part", p(os.date, "%Y")), - -- use matchNodes to insert text based on a pattern/function/lambda-evaluation. - s("mat", { - i(1, { "sample_text" }), - t(": "), - m(1, "%d", "contains a number", "no number :("), - }), - -- The inserted text defaults to the first capture group/the entire - -- match if there are none - s("mat2", { - i(1, { "sample_text" }), - t(": "), - m(1, "[abc][abc][abc]"), - }), - -- It is even possible to apply gsubs' or other transformations - -- before matching. - s("mat3", { - i(1, { "sample_text" }), - t(": "), - m( - 1, - l._1:gsub("[123]", ""):match("%d"), - "contains a number that isn't 1, 2 or 3!" - ), - }), - -- `match` also accepts a function, which in turn accepts a string - -- (text in node, \n-concatted) and returns any non-nil value to match. - -- If that value is a string, it is used for the default-inserted text. - s("mat4", { - i(1, { "sample_text" }), - t(": "), - m(1, function(text) - return (#text % 2 == 0 and text) or nil - end), - }), - -- The nonempty-node inserts text depending on whether the arg-node is - -- empty. - s("nempty", { - i(1, "sample_text"), - n(1, "i(1) is not empty!"), - }), - -- dynamic lambdas work exactly like regular lambdas, except that they - -- don't return a textNode, but a dynamicNode containing one insertNode. - -- This makes it easier to dynamically set preset-text for insertNodes. - s("dl1", { - i(1, "sample_text"), - t({ ":", "" }), - dl(2, l._1, 1), - }), - -- Obviously, it's also possible to apply transformations, just like lambdas. - s("dl2", { - i(1, "sample_text"), - i(2, "sample_text_2"), - t({ "", "" }), - dl(3, l._1:gsub("\n", " linebreak ") .. l._2, { 1, 2 }), - }), - -- Alternative printf-like notation for defining snippets. It uses format - -- string with placeholders similar to the ones used with Python's .format(). - s( - "fmt1", - fmt("To {title} {} {}.", { - i(2, "Name"), - i(3, "Surname"), - title = c(1, { t("Mr."), t("Ms.") }), - }) - ), - -- To escape delimiters use double them, e.g. `{}` -> `{{}}`. - -- Multi-line format strings by default have empty first/last line removed. - -- Indent common to all lines is also removed. Use the third `opts` argument - -- to control this behaviour. - s( - "fmt2", - fmt( - [[ - foo({1}, {3}) {{ - return {2} * {4} - }} - ]], - { - i(1, "x"), - r(1), - i(2, "y"), - r(2), - } - ) - ), - -- Empty placeholders are numbered automatically starting from 1 or the last - -- value of a numbered placeholder. Named placeholders do not affect numbering. - s( - "fmt3", - fmt("{} {a} {} {1} {}", { - t("1"), - t("2"), - a = t("A"), - }) - ), - -- The delimiters can be changed from the default `{}` to something else. - s( - "fmt4", - fmt("foo() { return []; }", i(1, "x"), { delimiters = "[]" }) - ), - -- `fmta` is a convenient wrapper that uses `<>` instead of `{}`. - s("fmt5", fmta("foo() { return <>; }", i(1, "x"))), - -- By default all args must be used. Use strict=false to disable the check - s( - "fmt6", - fmt("use {} only", { t("this"), t("not this") }, { strict = false }) - ), - }, -} + -- When regTrig is set, trig is treated like a pattern, this snippet will expand after any number. + ls.parser.parse_snippet({ trig = "%d", regTrig = true }, "A Number!!"), + -- Using the condition, it's possible to allow expansion only in specific cases. + s("cond", { + t("will only expand in c-style comments"), + }, { + condition = function(line_to_cursor, matched_trigger, captures) + -- optional whitespace followed by // + return line_to_cursor:match("%s*//") + end, + }), + -- there's some built-in conditions in "luasnip.extras.expand_conditions". + s("cond2", { + t("will only expand at the beginning of the line"), + }, { + condition = conds.line_begin, + }), + -- The last entry of args passed to the user-function is the surrounding snippet. + s( + { trig = "a%d", regTrig = true }, + f(function(_, snip) + return "Triggered with " .. snip.trigger .. "." + end, {}) + ), + -- It's possible to use capture-groups inside regex-triggers. + s( + { trig = "b(%d)", regTrig = true }, + f(function(_, snip) + return "Captured Text: " .. snip.captures[1] .. "." + end, {}) + ), + s({ trig = "c(%d+)", regTrig = true }, { + t("will only expand for even numbers"), + }, { + condition = function(line_to_cursor, matched_trigger, captures) + return tonumber(captures[1]) % 2 == 0 + end, + }), + -- Use a function to execute any shell command and print its text. + s("bash", f(bash, {}, "ls")), + -- Short version for applying String transformations using function nodes. + s("transform", { + i(1, "initial text"), + t({ "", "" }), + -- lambda nodes accept an l._1,2,3,4,5, which in turn accept any string transformations. + -- This list will be applied in order to the first node given in the second argument. + l(l._1:match("[^i]*$"):gsub("i", "o"):gsub(" ", "_"):upper(), 1), + }), + s("transform2", { + i(1, "initial text"), + t("::"), + i(2, "replacement for e"), + t({ "", "" }), + -- Lambdas can also apply transforms USING the text of other nodes: + l(l._1:gsub("e", l._2), { 1, 2 }), + }), + s({ trig = "trafo(%d+)", regTrig = true }, { + -- env-variables and captures can also be used: + l(l.CAPTURE1:gsub("1", l.TM_FILENAME), {}), + }), + -- Set store_selection_keys = "" (for example) in your + -- luasnip.config.setup() call to access TM_SELECTED_TEXT. In + -- this case, select a URL, hit Tab, then expand this snippet. + s("link_url", { + t(''), + i(1), + t(""), + i(0), + }), + -- Shorthand for repeating the text in a given node. + s("repeat", { i(1, "text"), t({ "", "" }), r(1) }), + -- Directly insert the ouput from a function evaluated at runtime. + s("part", p(os.date, "%Y")), + -- use matchNodes to insert text based on a pattern/function/lambda-evaluation. + s("mat", { + i(1, { "sample_text" }), + t(": "), + m(1, "%d", "contains a number", "no number :("), + }), + -- The inserted text defaults to the first capture group/the entire + -- match if there are none + s("mat2", { + i(1, { "sample_text" }), + t(": "), + m(1, "[abc][abc][abc]"), + }), + -- It is even possible to apply gsubs' or other transformations + -- before matching. + s("mat3", { + i(1, { "sample_text" }), + t(": "), + m( + 1, + l._1:gsub("[123]", ""):match("%d"), + "contains a number that isn't 1, 2 or 3!" + ), + }), + -- `match` also accepts a function, which in turn accepts a string + -- (text in node, \n-concatted) and returns any non-nil value to match. + -- If that value is a string, it is used for the default-inserted text. + s("mat4", { + i(1, { "sample_text" }), + t(": "), + m(1, function(text) + return (#text % 2 == 0 and text) or nil + end), + }), + -- The nonempty-node inserts text depending on whether the arg-node is + -- empty. + s("nempty", { + i(1, "sample_text"), + n(1, "i(1) is not empty!"), + }), + -- dynamic lambdas work exactly like regular lambdas, except that they + -- don't return a textNode, but a dynamicNode containing one insertNode. + -- This makes it easier to dynamically set preset-text for insertNodes. + s("dl1", { + i(1, "sample_text"), + t({ ":", "" }), + dl(2, l._1, 1), + }), + -- Obviously, it's also possible to apply transformations, just like lambdas. + s("dl2", { + i(1, "sample_text"), + i(2, "sample_text_2"), + t({ "", "" }), + dl(3, l._1:gsub("\n", " linebreak ") .. l._2, { 1, 2 }), + }), + -- Alternative printf-like notation for defining snippets. It uses format + -- string with placeholders similar to the ones used with Python's .format(). + s( + "fmt1", + fmt("To {title} {} {}.", { + i(2, "Name"), + i(3, "Surname"), + title = c(1, { t("Mr."), t("Ms.") }), + }) + ), + -- To escape delimiters use double them, e.g. `{}` -> `{{}}`. + -- Multi-line format strings by default have empty first/last line removed. + -- Indent common to all lines is also removed. Use the third `opts` argument + -- to control this behaviour. + s( + "fmt2", + fmt( + [[ + foo({1}, {3}) {{ + return {2} * {4} + }} + ]], + { + i(1, "x"), + r(1), + i(2, "y"), + r(2), + } + ) + ), + -- Empty placeholders are numbered automatically starting from 1 or the last + -- value of a numbered placeholder. Named placeholders do not affect numbering. + s( + "fmt3", + fmt("{} {a} {} {1} {}", { + t("1"), + t("2"), + a = t("A"), + }) + ), + -- The delimiters can be changed from the default `{}` to something else. + s( + "fmt4", + fmt("foo() { return []; }", i(1, "x"), { delimiters = "[]" }) + ), + -- `fmta` is a convenient wrapper that uses `<>` instead of `{}`. + s("fmt5", fmta("foo() { return <>; }", i(1, "x"))), + -- By default all args must be used. Use strict=false to disable the check + s( + "fmt6", + fmt("use {} only", { t("this"), t("not this") }, { strict = false }) + ), +}, { + key = "all", + }) -- autotriggered snippets have to be defined in a separate table, luasnip.autosnippets. ls.autosnippets = { From e23ea8343a0a40f387363db961b52881ec2d12f6 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 29 Apr 2022 00:21:30 +0200 Subject: [PATCH 25/52] [nvim] feat: write latex keymaps the 0.7 way --- .config/nvim/after/ftplugin/tex.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/nvim/after/ftplugin/tex.lua b/.config/nvim/after/ftplugin/tex.lua index 8ec747a..ac56e00 100644 --- a/.config/nvim/after/ftplugin/tex.lua +++ b/.config/nvim/after/ftplugin/tex.lua @@ -10,13 +10,13 @@ opt.formatoptions = "trq1jp" opt.tabstop = 4 -- Caps -utils.map("i", "AA", "À") -utils.map("i", "CC", "Ç") -utils.map("i", "EE", "É") +vim.keymap.set("i", "AA", "À") +vim.keymap.set("i", "CC", "Ç") +vim.keymap.set("i", "EE", "É") -- Unbreakable spaces -utils.map("i", "etc", "\\,etc.") -utils.map("i", ":", "\\,:") +vim.keymap.set("i", "etc", "\\,etc.") +vim.keymap.set("i", ":", "\\,:") -- Snippets local ls = require("luasnip") From 695cd74e5455c30eb1e63f26b302d5cab7d114a1 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 29 Apr 2022 00:23:08 +0200 Subject: [PATCH 26/52] [nvim] feat: custom (colored) nodes for snippets --- .config/nvim/lua/plugin/luasnip.lua | 21 ++++++++++++++++++++- .local/src/astronomy.nvim | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugin/luasnip.lua b/.config/nvim/lua/plugin/luasnip.lua index b88b007..c5415c1 100644 --- a/.config/nvim/lua/plugin/luasnip.lua +++ b/.config/nvim/lua/plugin/luasnip.lua @@ -31,7 +31,26 @@ ls.config.set_config({ ext_opts = { [types.choiceNode] = { active = { - virt_text = { { "choiceNode", "Comment" } }, + virt_text = { { "●", "LuaSnipChoice" } }, + }, + inactive = { + virt_text = { { "●", "LuaSnipInactive" } }, + }, + }, + [types.functionNode] = { + active = { + virt_text = { { "●", "LuaSnipFunction" } }, + }, + inactive = { + virt_text = { { "●", "LuaSnipInactive" } }, + }, + }, + [types.insertNode] = { + active = { + virt_text = { { "●", "LuaSnipInsert" } }, + }, + inactive = { + virt_text = { { "●", "LuaSnipInactive" } }, }, }, }, diff --git a/.local/src/astronomy.nvim b/.local/src/astronomy.nvim index d77e1cf..9b46e0f 160000 --- a/.local/src/astronomy.nvim +++ b/.local/src/astronomy.nvim @@ -1 +1 @@ -Subproject commit d77e1cfe127418ab00c6d5fb076f89cdf9b49e94 +Subproject commit 9b46e0fa3d2bfca3b376961d822eb5d965da48ed From c29a53ac5877a1c4af1eec266c40b50f6662ec5c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 1 May 2022 14:41:20 +0200 Subject: [PATCH 27/52] [mail] feat: change Centrale displayed name is now "Smecta" --- .../mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc b/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc index a4aa0c7..55a8192 100644 --- a/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc +++ b/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc @@ -1,6 +1,6 @@ # vim: filetype=neomuttrc # muttrc file for account david.julien@centrale-marseille.fr -set realname = "David JULIEN" +set realname = "Smecta" set from = "david.julien@centrale-marseille.fr" set sendmail = "msmtp -a david.julien@centrale-marseille.fr" alias me david.julien From 8f73067a9becf6d4a4a03198218fa2bfa8213b25 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 1 May 2022 14:42:05 +0200 Subject: [PATCH 28/52] [nvim] fix: variable names conflicts --- .config/nvim/lua/plugin/luasnip.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugin/luasnip.lua b/.config/nvim/lua/plugin/luasnip.lua index c5415c1..9fb6719 100644 --- a/.config/nvim/lua/plugin/luasnip.lua +++ b/.config/nvim/lua/plugin/luasnip.lua @@ -74,10 +74,12 @@ end -- Returns a snippet_node wrapped around an insert_node whose initial -- text value is set to the current date in the desired format. local function date_input(fmt) - local fmt = fmt or "%Y-%m-%d" - return sn(nil, i(1, os.date(fmt))) + local format = fmt or "%Y-%m-%d" + return sn(nil, i(1, os.date(format))) end +local copy = utils.copy + -- snippets are added via ls.add_snippets(filetype, snippets[, opts]), where -- opts may specify the `type` of the snippets ("snippets" or "autosnippets", -- for snippets that should expand directly after the trigger is typed). From f0596d3c808f15b41a44c71b2892dd84e27c8bf8 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 1 May 2022 14:43:00 +0200 Subject: [PATCH 29/52] [nvim] refactor: move CompletionItems to cmp.lua --- .config/nvim/lua/plugin/cmp.lua | 40 ++++++++++++++++++++++++++ .config/nvim/lua/plugin/lsp_config.lua | 40 -------------------------- .config/nvim/lua/plugin/packer.lua | 2 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index 92e29b2..4155b68 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -17,6 +17,45 @@ end -- If you want insert `(` after select function or method item cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) +-- Custom item icons +local icons = { + Class = "  ", + Color = "  ", + Constant = " µ ", + Constructor = "  ", + Enum = "  ", + EnumMember = "  ", + Event = "  ", + Field = "  ", + File = "  ", + Folder = "  ", + Function = "  ", + Keyword = "  ", + Interface = "  ", + Method = "  ", + Module = "  ", + Operator = "  ", + Property = "  ", + Reference = "  ", + Snippet = "  ", + Struct = "  ", + Text = "  ", + TypeParameter = "  ", + Unit = "  ", + Value = "  ", + Variable = "  ", +} + + +local function icons_setup() + local kinds = vim.lsp.protocol.CompletionItemKind + for i, kind in ipairs(kinds) do + kinds[i] = icons[kind] or kind + end +end + + + cmp.setup { completion = { autocomplete = false @@ -33,6 +72,7 @@ cmp.setup { }, formatting = { format = function(entry, vim_item) + vim_item.kind = icons[vim_item.kind] vim_item.menu = ({ nvim_lsp = "[lsp]", nvim_lua = "[nvim]", diff --git a/.config/nvim/lua/plugin/lsp_config.lua b/.config/nvim/lua/plugin/lsp_config.lua index fb00539..e593c90 100644 --- a/.config/nvim/lua/plugin/lsp_config.lua +++ b/.config/nvim/lua/plugin/lsp_config.lua @@ -3,8 +3,6 @@ -- License : GPLv3 -- Description : neovim lsp config file -local M = {} - vim.fn.sign_define( "DiagnosticSignError", { @@ -37,41 +35,3 @@ vim.fn.sign_define( numhl = "DiagnosticSignInfo" } ) - -M.icons = { - Class = "  ", - Color = "  ", - Constant = " µ ", - Constructor = "  ", - Enum = "  ", - EnumMember = "  ", - Event = "  ", - Field = "  ", - File = "  ", - Folder = "  ", - Function = "  ", - Keyword = "  ", - Interface = "  ", - Method = "  ", - Module = "  ", - Operator = "  ", - Property = "  ", - Reference = "  ", - Snippet = "  ", - Struct = "  ", - Text = "  ", - TypeParameter = "  ", - Unit = "  ", - Value = "  ", - Variable = "  ", -} - - -function M.setup() - local kinds = vim.lsp.protocol.CompletionItemKind - for i, kind in ipairs(kinds) do - kinds[i] = M.icons[kind] or kind - end -end - -return M diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index dddeee8..9ab4a3b 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -58,7 +58,7 @@ return require("packer").startup(function() requires = { "neovim/nvim-lspconfig", config = function() - require("plugin.lsp_config").setup() end + require("plugin.lsp_config") end }, config = function() require("plugin.lsp_installer") end } From 375f82d8e6a3e2c391f4492b9f42e44ea1bca503 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 1 May 2022 18:30:12 +0200 Subject: [PATCH 30/52] [nvim] refactor: trim down lsp icons + remove unused functions --- .config/nvim/lua/plugin/cmp.lua | 68 +++++++++++++++------------------ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index 4155b68..c12ce81 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -19,43 +19,33 @@ cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex -- Custom item icons local icons = { - Class = "  ", - Color = "  ", - Constant = " µ ", - Constructor = "  ", - Enum = "  ", - EnumMember = "  ", - Event = "  ", - Field = "  ", - File = "  ", - Folder = "  ", - Function = "  ", - Keyword = "  ", - Interface = "  ", - Method = "  ", - Module = "  ", - Operator = "  ", - Property = "  ", - Reference = "  ", - Snippet = "  ", - Struct = "  ", - Text = "  ", - TypeParameter = "  ", - Unit = "  ", - Value = "  ", - Variable = "  ", + Class = "", + Color = "", + Constant = "µ", + Constructor = "", + Enum = "", + EnumMember = "", + Event = "", + Field = "", + File = "", + Folder = "", + Function = "", + Keyword = "", + Interface = "", + Method = "", + Module = "", + Operator = "", + Property = "", + Reference = "", + Snippet = "", + Struct = "", + Text = "", + TypeParameter = "", + Unit = "", + Value = "", + Variable = "", } - -local function icons_setup() - local kinds = vim.lsp.protocol.CompletionItemKind - for i, kind in ipairs(kinds) do - kinds[i] = icons[kind] or kind - end -end - - - cmp.setup { completion = { autocomplete = false @@ -72,7 +62,8 @@ cmp.setup { }, formatting = { format = function(entry, vim_item) - vim_item.kind = icons[vim_item.kind] + vim_item.kind = string.format("%s %s", icons[vim_item.kind], + vim_item.kind) vim_item.menu = ({ nvim_lsp = "[lsp]", nvim_lua = "[nvim]", @@ -119,5 +110,8 @@ cmp.setup { fallback() end end, { "i", "s" }), - } + }, + view = { + entries = {name = 'custom', selection_order = 'near_cursor' } + }, } From fb9ea761df8bf7b46f4382edf9e370965bc2b47a Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 1 May 2022 18:36:33 +0200 Subject: [PATCH 31/52] [nvim] feat: add nvim-cmp colors --- .local/src/astronomy.nvim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/src/astronomy.nvim b/.local/src/astronomy.nvim index 9b46e0f..41edd2a 160000 --- a/.local/src/astronomy.nvim +++ b/.local/src/astronomy.nvim @@ -1 +1 @@ -Subproject commit 9b46e0fa3d2bfca3b376961d822eb5d965da48ed +Subproject commit 41edd2a8502cc6d3be9ad18387e8b3c67d2dd4c3 From 0cb56c9a46dc7e1a0d91bf53608e628edfcfc036 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 1 May 2022 18:37:27 +0200 Subject: [PATCH 32/52] [dwm] feat: add screenshot script + keymap --- .config/sxhkd/sxhkdrc | 3 +++ .local/bin/screenshot | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100755 .local/bin/screenshot diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 687ef73..0538d1f 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -50,6 +50,9 @@ super + shift + Return super + d dmenu_run -p "run:" +super + p + screenshot + super + shift + {w,z} $BROWSER diff --git a/.local/bin/screenshot b/.local/bin/screenshot new file mode 100755 index 0000000..8c4c684 --- /dev/null +++ b/.local/bin/screenshot @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +if [ "-w" = "$1" ]; then + scrot -e 'xclip -selection clipboard -t image/png -i $f && rm $f' +else + if [ ! "" = "$1" ]; then + dunstify -u "normal" " Wrong parameter. No screenshot taken" && exit 1 + else + scrot -s -e 'xclip -selection clipboard -t image/png -i $f && rm $f' + fi +fi From 407d9983a82c06efbff74f1d1ea8cbb5ac32975c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 2 May 2022 23:32:25 +0200 Subject: [PATCH 33/52] [nvim] fix: statusline diagnostics diagnostics are buffer-specific --- .config/nvim/lua/statusline.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua index 88d438a..6d21c4e 100644 --- a/.config/nvim/lua/statusline.lua +++ b/.config/nvim/lua/statusline.lua @@ -99,7 +99,7 @@ local function get_mode_color(m) end -- from https://github.com/nvim-lua/lsp-status.nvim/blob/master/lua/lsp-status/diagnostics.lua -local function get_lsp_diagnostics(bufnr) +local function get_lsp_diagnostics() local result = {} local levels = { errors = "Error", @@ -110,7 +110,7 @@ local function get_lsp_diagnostics(bufnr) for k, level in pairs(levels) do local count = 0 - local diags = vim.diagnostic.get(bufnr, { severity = level }) + local diags = vim.diagnostic.get(0, { severity = level }) for _, _ in pairs(diags) do count = count + 1 end From f20223da5779d478aaec8dbcc0675dd629ef5849 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 2 May 2022 23:35:31 +0200 Subject: [PATCH 34/52] [nvim] feat: update lsp config to follow plugins nvim-lsp-installer stopped setting things up, setup lsp through lspconfig --- .config/nvim/lua/plugin/backup | 130 ++++++++++++++++++++ .config/nvim/lua/plugin/lsp/clangd.lua | 23 ++++ .config/nvim/lua/plugin/lsp/init.lua | 100 +++++++++++++++ .config/nvim/lua/plugin/lsp/sumneko_lua.lua | 47 +++++++ .config/nvim/lua/plugin/lsp_config.lua | 37 ------ .config/nvim/lua/plugin/lsp_installer.lua | 129 ------------------- .config/nvim/lua/plugin/packer.lua | 8 +- 7 files changed, 303 insertions(+), 171 deletions(-) create mode 100644 .config/nvim/lua/plugin/backup create mode 100644 .config/nvim/lua/plugin/lsp/clangd.lua create mode 100644 .config/nvim/lua/plugin/lsp/init.lua create mode 100644 .config/nvim/lua/plugin/lsp/sumneko_lua.lua delete mode 100644 .config/nvim/lua/plugin/lsp_config.lua delete mode 100644 .config/nvim/lua/plugin/lsp_installer.lua diff --git a/.config/nvim/lua/plugin/backup b/.config/nvim/lua/plugin/backup new file mode 100644 index 0000000..3a051ee --- /dev/null +++ b/.config/nvim/lua/plugin/backup @@ -0,0 +1,130 @@ +-- Author : swytch +-- Created : Saturday Sept. 11, 2021 22:12:33 CET +-- License : GPLv3 +-- Description : nvim-lsp-installer plugin config file + +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.settings { + ui = { + icons = { + server_installed = "✓", + server_pending = "o", + server_uninstalled = "x" + } + } +} + +local servers = { + "clangd", + "sumneko_lua", +} + +for _, name in ipairs(servers) do + local ok, server = lsp_installer.get_server(name) + -- Check that the server is supported in nvim-lsp-installer + if ok then + if not server:is_installed() then + print("Installing " .. name) + server:install() + end + end +end + +local lsp_root_path = vim.fn.stdpath("data") .. "/lsp_servers/" +local runtime_path = vim.split(package.path, ';') +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") +local enhance_server_opts = { + ["clangd"] = function(opts) + opts.settings = { + cmd = { lsp_root_path .. "clangd/clangd/bin/clangd", + "--background-index", + "--suggest-missing-includes", + "--clang-tidy", + "--header-insertion=iwyu" + }, + } + end, + ["sumneko_lua"] = function(opts) + opts.settings = { + cmd = { lsp_root_path + .. "sumneko_lua/extension/server/bin/" + .. "lua-language-server", + "-E", + lsp_root_path + .. "sumneko_lua/extension/server/main.lua" + }, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + "vim", + "use", + "globals", + "utils" + }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = + vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, + } + end, +} + +local on_attach = function(_, bufnr) + local opts = { buffer = bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', + vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', + vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + vim.inspect(vim.lsp.buf.list_workspace_folders()) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'so', + require('telescope.builtin').lsp_document_symbols, opts) + vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {}) +end + +-- nvim-cmp supports additional completion capabilities +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) + +lsp_installer.on_server_ready(function(server) + -- Specify the default options which we'll use to setup all servers + local opts = { + on_attach = on_attach, + capabilities = capabilities, + } + + if enhance_server_opts[server.name] then + -- Enhance the default opts with the server-specific ones + enhance_server_opts[server.name](opts) + end + + server:setup(opts) +end) diff --git a/.config/nvim/lua/plugin/lsp/clangd.lua b/.config/nvim/lua/plugin/lsp/clangd.lua new file mode 100644 index 0000000..5996b05 --- /dev/null +++ b/.config/nvim/lua/plugin/lsp/clangd.lua @@ -0,0 +1,23 @@ +-- Author : swytch +-- Created : Monday May 2, 2022 21:00:24 CET +-- License : GPLv3 +-- Description : neovim lsp config file for clangd + + +local M = {} + +local lsp_root_path = vim.fn.stdpath("data") .. "/lsp_servers/" +local clangd_binary = lsp_root_path .. "clangd/clangd/bin/clangd" + +M.setup = function(opts) + opts.settings = { + cmd = { clangd_binary, + "--background-index", + "--suggest-missing-includes", + "--clang-tidy", + "--header-insertion=iwyu" + }, + } +end + +return M diff --git a/.config/nvim/lua/plugin/lsp/init.lua b/.config/nvim/lua/plugin/lsp/init.lua new file mode 100644 index 0000000..468a445 --- /dev/null +++ b/.config/nvim/lua/plugin/lsp/init.lua @@ -0,0 +1,100 @@ +-- Author : swytch +-- Created : Monday May 2, 2022 21:02:02 CET +-- License : GPLv3 +-- Description : neovim global lsp config file + + +local lspconfig = require("lspconfig") +local lsp_installer = require("nvim-lsp-installer") + +local globals = require("globals") +local signs = { + Error = globals.sign_error, + Warn = globals.sign_warn, + Hint = globals.sign_hint, + Info = globals.sign_info, +} + +for type, icon in ipairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { + text = icon, + texthl = hl, + numhl = hl + }) +end + +vim.diagnostic.config({ + update_in_insert = true +}) + + +local enhance_server_opts = { + ["clangd"] = function(opts) + require("plugin.lsp.clangd").setup(opts) + end, + ["sumneko_lua"] = function(opts) + require("plugin.lsp.sumneko_lua").setup(opts) + end, +} + +local on_attach = function(_, bufnr) + local opts = { buffer = bufnr } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "ln", vim.diagnostic.goto_next, opts) + vim.keymap.set("n", "lp", vim.diagnostic.goto_prev, opts) + vim.keymap.set("n", "lf", vim.lsp.buf.formatting, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "wa", + vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "wr", + vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set("n", "wl", function() + vim.inspect(vim.lsp.buf.list_workspace_folders()) + end, opts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "so", + require("telescope.builtin").lsp_document_symbols, opts) +end + +-- nvim-cmp supports additional completion capabilities +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) + +-- Enable the following language servers +local servers = { "clangd", "sumneko_lua" } +lsp_installer.setup { + ensure_installed = servers +} + +-- Setup nvim-lsp-installer +lsp_installer.settings { + ui = { + icons = { + server_installed = "✓", + server_pending = "o", + server_uninstalled = "x" + } + } +} + + +for _, server in ipairs(servers) do + local opts = { + on_attach = on_attach, + capabilities = capabilities, + } + + if enhance_server_opts[server] then + -- Enhance the default opts with the server-specific ones + enhance_server_opts[server](opts) + end + + lspconfig[server].setup(opts) +end diff --git a/.config/nvim/lua/plugin/lsp/sumneko_lua.lua b/.config/nvim/lua/plugin/lsp/sumneko_lua.lua new file mode 100644 index 0000000..931db91 --- /dev/null +++ b/.config/nvim/lua/plugin/lsp/sumneko_lua.lua @@ -0,0 +1,47 @@ +-- Author : swytch +-- Created : Monday May 2, 2022 21:00:07 CET +-- License : GPLv3 +-- Description : neovim lsp config file for sumneko_lua + + +local M = {} + +local runtime_path = vim.split(package.path, ';') + +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") + + +M.setup = function(opts) + opts.settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're + -- using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + "vim", + "globals", + "utils" + }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = + vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but + -- unique identifier + telemetry = { + enable = false, + }, + }, + } +end + +return M diff --git a/.config/nvim/lua/plugin/lsp_config.lua b/.config/nvim/lua/plugin/lsp_config.lua deleted file mode 100644 index e593c90..0000000 --- a/.config/nvim/lua/plugin/lsp_config.lua +++ /dev/null @@ -1,37 +0,0 @@ --- Author : swytch --- Created : Tuesday May 18, 2021 12:08:51 CET --- License : GPLv3 --- Description : neovim lsp config file - -vim.fn.sign_define( - "DiagnosticSignError", - { - texthl = "DiagnosticVirtualTextError", - text = globals.sign_error, - numhl = "DiagnosticSignError" - } -) -vim.fn.sign_define( - "DiagnosticSignWarn", - { - texthl = "DiagnosticVirtualTextWarn", - text = globals.sign_warning, - numhl = "DiagnosticSignWarn" - } -) -vim.fn.sign_define( - "DiagnosticSignHint", - { - texthl = "DiagnosticVirtualTextHint", - text = globals.sign_hint, - numhl = "DiagnosticSignHint" - } -) -vim.fn.sign_define( - "DiagnosticSignInfo", - { - texthl = "DiagnosticVirtualTextInfo", - text = globals.sign_info, - numhl = "DiagnosticSignInfo" - } -) diff --git a/.config/nvim/lua/plugin/lsp_installer.lua b/.config/nvim/lua/plugin/lsp_installer.lua deleted file mode 100644 index ab3b51c..0000000 --- a/.config/nvim/lua/plugin/lsp_installer.lua +++ /dev/null @@ -1,129 +0,0 @@ --- Author : swytch --- Created : Saturday Sept. 11, 2021 22:12:33 CET --- License : GPLv3 --- Description : nvim-lsp-installer plugin config file - -local lsp_installer = require("nvim-lsp-installer") - -lsp_installer.settings { - ui = { - icons = { - server_installed = "✓", - server_pending = "o", - server_uninstalled = "x" - } - } -} - -local servers = { - "clangd", - "sumneko_lua", -} - -for _, name in ipairs(servers) do - local ok, server = lsp_installer.get_server(name) - -- Check that the server is supported in nvim-lsp-installer - if ok then - if not server:is_installed() then - print("Installing " .. name) - server:install() - end - end -end - -local lsp_root_path = vim.fn.stdpath("data") .. "/lsp_servers/" -local runtime_path = vim.split(package.path, ';') - - -local clangd_binary = lsp_root_path .. "clangd/clangd/bin/clangd" - -table.insert(runtime_path, "lua/?.lua") -table.insert(runtime_path, "lua/?/init.lua") - -local enhance_server_opts = { - ["clangd"] = function(opts) - opts.settings = { - cmd = { clangd_binary, - "--background-index", - "--suggest-missing-includes", - "--clang-tidy", - "--header-insertion=iwyu" - }, - } - end, - ["sumneko_lua"] = function(opts) - opts.settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're - -- using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { - "vim", - "globals", - "utils" - }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = - vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but - -- unique identifier - telemetry = { - enable = false, - }, - }, - } - end, -} - -local on_attach = function(_, bufnr) - local opts = { buffer = bufnr } - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) - vim.keymap.set("n", "ln", vim.diagnostic.goto_next, opts) - vim.keymap.set("n", "lp", vim.diagnostic.goto_prev, opts) - vim.keymap.set("n", "lf", vim.lsp.buf.formatting, opts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) - vim.keymap.set("n", "wa", - vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set("n", "wr", - vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set("n", "wl", function() - vim.inspect(vim.lsp.buf.list_workspace_folders()) - end, opts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) - vim.keymap.set("n", "so", - require("telescope.builtin").lsp_document_symbols, opts) -end - --- nvim-cmp supports additional completion capabilities -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) - -lsp_installer.on_server_ready(function(server) - -- Specify the default options which we'll use to setup all servers - local opts = { - on_attach = on_attach, - capabilities = capabilities, - } - - if enhance_server_opts[server.name] then - -- Enhance the default opts with the server-specific ones - enhance_server_opts[server.name](opts) - end - - server:setup(opts) -end) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 9ab4a3b..fc3f020 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -54,13 +54,11 @@ return require("packer").startup(function() -- LSP use { - "williamboman/nvim-lsp-installer", + "neovim/nvim-lspconfig", requires = { - "neovim/nvim-lspconfig", - config = function() - require("plugin.lsp_config") end + "williamboman/nvim-lsp-installer", }, - config = function() require("plugin.lsp_installer") end + config = function() require("plugin.lsp") end } -- auto completion From 5d8c5ca6f4bba92540f38813a40832696654663d Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 3 May 2022 20:23:13 +0200 Subject: [PATCH 35/52] [scripts] fix: screenshot also add header --- .local/bin/screenshot | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.local/bin/screenshot b/.local/bin/screenshot index 8c4c684..335f4b8 100755 --- a/.local/bin/screenshot +++ b/.local/bin/screenshot @@ -1,4 +1,17 @@ #!/usr/bin/env sh + +###################################################################### +# @author : swytch +# @file : screenshot +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:52:58 CEST +# +# @description : grab a screenshot +# @deps : scrot xclip dunstify +###################################################################### + + +sleep .1 if [ "-w" = "$1" ]; then scrot -e 'xclip -selection clipboard -t image/png -i $f && rm $f' else From f25ef3e9be042d56154f43440bda7c34e4d0d719 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 4 May 2022 22:58:42 +0200 Subject: [PATCH 36/52] [nvim] feat: cleanup server setup --- .config/nvim/lua/plugin/lsp/init.lua | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/.config/nvim/lua/plugin/lsp/init.lua b/.config/nvim/lua/plugin/lsp/init.lua index 468a445..3810d38 100644 --- a/.config/nvim/lua/plugin/lsp/init.lua +++ b/.config/nvim/lua/plugin/lsp/init.lua @@ -28,16 +28,6 @@ vim.diagnostic.config({ update_in_insert = true }) - -local enhance_server_opts = { - ["clangd"] = function(opts) - require("plugin.lsp.clangd").setup(opts) - end, - ["sumneko_lua"] = function(opts) - require("plugin.lsp.sumneko_lua").setup(opts) - end, -} - local on_attach = function(_, bufnr) local opts = { buffer = bufnr } vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) @@ -67,34 +57,27 @@ end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) --- Enable the following language servers +-- Setup nvim-lsp-installer local servers = { "clangd", "sumneko_lua" } lsp_installer.setup { - ensure_installed = servers -} - --- Setup nvim-lsp-installer -lsp_installer.settings { + ensure_installed = servers, ui = { icons = { server_installed = "✓", server_pending = "o", - server_uninstalled = "x" + server_uninstalled = "" } } } - for _, server in ipairs(servers) do local opts = { on_attach = on_attach, capabilities = capabilities, } - if enhance_server_opts[server] then - -- Enhance the default opts with the server-specific ones - enhance_server_opts[server](opts) - end + local plugin = string.format("%s.%s", "plugin.lsp", server) + require(plugin).setup(opts) lspconfig[server].setup(opts) end From 583121534cc26dd7353722f97efbb059638e4914 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 4 May 2022 22:59:13 +0200 Subject: [PATCH 37/52] [nvim] feat: custom icons for packer also require it at the beginning --- .config/nvim/lua/plugin/packer.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index fc3f020..16cda69 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -1,9 +1,10 @@ -- Author : swytch -- Created : Friday Mar 12, 2021 22:28:34 CET -- License : GPLv3 --- Description : neovim plugins file +-- Description : neovim packer config file +local packer = require("packer") local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(install_path)) > 0 then print("Cloning packer...") @@ -19,7 +20,18 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then print("Done.") end -local use = require("packer").use +packer.init({ + display = { + working_sym = 'o', -- The symbol for a plugin being installed/updated + error_sym = '', -- The symbol for a plugin with an error in installation/updating + done_sym = '✓', -- The symbol for a plugin which has completed installation/updating + removed_sym = '-', -- The symbol for an unused plugin which was removed + moved_sym = '→', -- The symbol for a plugin which was moved (e.g. from opt to start) + header_sym = '━', -- The symbol for the header line in packer's display + }, +}) + +local use = packer.use return require("packer").startup(function() -- packer manages itself From 0c0baaaadf116cbc9ec0c91663efe283a80f1381 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 17 May 2022 12:00:02 +0200 Subject: [PATCH 38/52] [ncmpcpp] feat: tweak colors to be readable in both ligh and dark themes --- .config/ncmpcpp/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ncmpcpp/config b/.config/ncmpcpp/config index 5efb1a6..26d9c20 100644 --- a/.config/ncmpcpp/config +++ b/.config/ncmpcpp/config @@ -234,7 +234,7 @@ mpd_music_dir = ~/music song_list_format = "{$3[%l]$9} {$6%t$9}|{$6%30f$9} %n" #song_list_format = {%a - }{%t}|{$8%f$9}$R{$3%l$9} # -song_status_format = $b {$3%a$9 - $7{%t}}|{%f} {(%b)} +song_status_format = $b {$7%a$9 - $6{%t}}|{%f} {(%b)} #song_status_format = {{%a{ "%b"{ (%y)}} - }{%t}}|{%f} # #song_library_format = {%n - }{%t}|{%f} @@ -313,7 +313,7 @@ song_status_format = $b {$3%a$9 - $7{%t}}|{%f} {(%b)} ## available. ## # -song_columns_list_format = (6f)[green]{NE} (30)[white]{t|f:Title} (7f)[green]{l} (30)[]{a} (30)[]{b} +song_columns_list_format = (6f)[]{NE} (30)[magenta]{t|f:Title} (7f)[green]{l} (30)[blue]{a} (30)[blue]{b} #song_columns_list_format = (20)[]{a} (6f)[green]{NE} (50)[white]{t|f:Title} (20)[cyan]{b} (7f)[magenta]{l} # ##### various settings ##### From 33f4267a618443fb26a80aa53c5a3abccea038b4 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 17 May 2022 16:20:52 +0200 Subject: [PATCH 39/52] [sxhkd] feat: add slock keymap --- .config/sxhkd/sxhkdrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 0538d1f..be50e52 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -25,6 +25,9 @@ super + shift + s super + shift + r dmenuprompt "reboot?" "reboot" +super + BackSpace + slock + super + shift + d displayselect From 9360696302c5a539f9fa9a6462ab7d21dac3f80c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 17 May 2022 16:23:07 +0200 Subject: [PATCH 40/52] [sxhkd] feat: alt key to tweak mappings --- .config/sxhkd/sxhkdrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index be50e52..3d9394e 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -40,7 +40,7 @@ super + shift + o super + c switch-colors -super + shift + c +super + alt + c switch-colors -s # Others From 9a076e3984a9b169ef2fda8159b8c8b89450bde0 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 17 May 2022 16:23:44 +0200 Subject: [PATCH 41/52] [sxhkd] feat: add screenshot -w keymap --- .config/sxhkd/sxhkdrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 3d9394e..7aa4bed 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -56,6 +56,9 @@ super + d super + p screenshot +super + alt + p + screenshot -w + super + shift + {w,z} $BROWSER From 015c7f3936d33f45cc800a4a0d23002c732b6e11 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 17 May 2022 16:45:58 +0200 Subject: [PATCH 42/52] [nvim] feat: add latex lsp --- .config/nvim/lua/plugin/lsp/init.lua | 2 +- .config/nvim/lua/plugin/lsp/texlab.lua | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/lua/plugin/lsp/texlab.lua diff --git a/.config/nvim/lua/plugin/lsp/init.lua b/.config/nvim/lua/plugin/lsp/init.lua index 3810d38..86f73d0 100644 --- a/.config/nvim/lua/plugin/lsp/init.lua +++ b/.config/nvim/lua/plugin/lsp/init.lua @@ -58,7 +58,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) -- Setup nvim-lsp-installer -local servers = { "clangd", "sumneko_lua" } +local servers = { "clangd", "sumneko_lua", "texlab" } lsp_installer.setup { ensure_installed = servers, ui = { diff --git a/.config/nvim/lua/plugin/lsp/texlab.lua b/.config/nvim/lua/plugin/lsp/texlab.lua new file mode 100644 index 0000000..2fbbf14 --- /dev/null +++ b/.config/nvim/lua/plugin/lsp/texlab.lua @@ -0,0 +1,18 @@ +-- Author : swytch +-- Created : Monday May 17, 2022 16:29:18 CET +-- License : GPLv3 +-- Description : neovim lsp config file for texlab + + +local M = {} + +M.setup = function(opts) + opts.settings = { + build = { + executable = "pdflatex" + } + } +end + +return M + From 6bdf71567fd0254f4bb446d4381b781368ba1e49 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Thu, 19 May 2022 15:08:44 +0200 Subject: [PATCH 43/52] [nvim] fix: no newline after itemize in tex files --- .config/nvim/after/ftplugin/tex.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/nvim/after/ftplugin/tex.lua b/.config/nvim/after/ftplugin/tex.lua index ac56e00..39f2bd3 100644 --- a/.config/nvim/after/ftplugin/tex.lua +++ b/.config/nvim/after/ftplugin/tex.lua @@ -52,7 +52,7 @@ ls.add_snippets("tex", { i(1), t({ "" }), d(2, rec_ls, {}), - t({ "", "\\end{itemize}", "" }), + t({ "", "\\end{itemize}" }), }), s("lsl", { t({ "\\begin{itemize}[label=" }), @@ -61,7 +61,7 @@ ls.add_snippets("tex", { i(2), t({ "" }), d(3, rec_ls, {}), - t({ "", "\\end{itemize}", "" }), + t({ "", "\\end{itemize}" }), }), s("frm", { t({ "\\begin{" }), @@ -76,7 +76,7 @@ ls.add_snippets("tex", { i(0), t({ "", "\\end{" }), f(copy, 1), - t({ "}", "" }), + t({ "}" }), }), s("env", { t({ "\\begin{" }), From 12182ea487e1aac3fd1507324629f9f8268f5aa1 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 31 May 2022 17:21:29 +0200 Subject: [PATCH 44/52] [nvim] fix: lsp hints in signbar --- .config/nvim/lua/plugin/lsp/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugin/lsp/init.lua b/.config/nvim/lua/plugin/lsp/init.lua index 86f73d0..88be39c 100644 --- a/.config/nvim/lua/plugin/lsp/init.lua +++ b/.config/nvim/lua/plugin/lsp/init.lua @@ -15,7 +15,7 @@ local signs = { Info = globals.sign_info, } -for type, icon in ipairs(signs) do +for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, @@ -57,7 +57,6 @@ end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) --- Setup nvim-lsp-installer local servers = { "clangd", "sumneko_lua", "texlab" } lsp_installer.setup { ensure_installed = servers, From 5689005285fe1871fb6790a54eae07e7492f577a Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 31 May 2022 17:24:31 +0200 Subject: [PATCH 45/52] [scripts] feat: compile luatex + main project if exists --- .local/bin/compiler | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.local/bin/compiler b/.local/bin/compiler index 322a628..e9eeb94 100755 --- a/.local/bin/compiler +++ b/.local/bin/compiler @@ -31,15 +31,21 @@ shebangtest() } texcompile() { \ + [ -e "main.tex" ] && base="main" && file="$base.tex" + cmd="pdflatex" + case "$(head -n 1 $file)" in + *lua*) cmd="lualatex" ;; + esac bibliography="$(grep '\\bibliography' "$file")" + if [ -n "$bibliography" ]; then - pdflatex --output-directory="$dir" "$base" && + $cmd --output-directory="$dir" "$base" && bibtex "$base" && - pdflatex --output-directory="$dir" "$base" && - pdflatex --output-directory="$dir" "$base" + $cmd --output-directory="$dir" "$base" && + $cmd --output-directory="$dir" "$base" else - pdflatex --output-directory="$dir" "$base" && - pdflatex --output-directory="$dir" "$base" + $cmd --output-directory="$dir" "$base" && + $cmd --output-directory="$dir" "$base" fi } From 96b6b535a558e8caa3ae9591d7f9a5bf58a6b088 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 31 May 2022 17:31:35 +0200 Subject: [PATCH 46/52] [nvim] cleanup: remove unused backup file --- .config/nvim/lua/plugin/backup | 130 --------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 .config/nvim/lua/plugin/backup diff --git a/.config/nvim/lua/plugin/backup b/.config/nvim/lua/plugin/backup deleted file mode 100644 index 3a051ee..0000000 --- a/.config/nvim/lua/plugin/backup +++ /dev/null @@ -1,130 +0,0 @@ --- Author : swytch --- Created : Saturday Sept. 11, 2021 22:12:33 CET --- License : GPLv3 --- Description : nvim-lsp-installer plugin config file - -local lsp_installer = require("nvim-lsp-installer") - -lsp_installer.settings { - ui = { - icons = { - server_installed = "✓", - server_pending = "o", - server_uninstalled = "x" - } - } -} - -local servers = { - "clangd", - "sumneko_lua", -} - -for _, name in ipairs(servers) do - local ok, server = lsp_installer.get_server(name) - -- Check that the server is supported in nvim-lsp-installer - if ok then - if not server:is_installed() then - print("Installing " .. name) - server:install() - end - end -end - -local lsp_root_path = vim.fn.stdpath("data") .. "/lsp_servers/" -local runtime_path = vim.split(package.path, ';') -table.insert(runtime_path, "lua/?.lua") -table.insert(runtime_path, "lua/?/init.lua") -local enhance_server_opts = { - ["clangd"] = function(opts) - opts.settings = { - cmd = { lsp_root_path .. "clangd/clangd/bin/clangd", - "--background-index", - "--suggest-missing-includes", - "--clang-tidy", - "--header-insertion=iwyu" - }, - } - end, - ["sumneko_lua"] = function(opts) - opts.settings = { - cmd = { lsp_root_path - .. "sumneko_lua/extension/server/bin/" - .. "lua-language-server", - "-E", - lsp_root_path - .. "sumneko_lua/extension/server/main.lua" - }, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { - "vim", - "use", - "globals", - "utils" - }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = - vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, - } - end, -} - -local on_attach = function(_, bufnr) - local opts = { buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'wa', - vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set('n', 'wr', - vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set('n', 'wl', function() - vim.inspect(vim.lsp.buf.list_workspace_folders()) - end, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'so', - require('telescope.builtin').lsp_document_symbols, opts) - vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {}) -end - --- nvim-cmp supports additional completion capabilities -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) - -lsp_installer.on_server_ready(function(server) - -- Specify the default options which we'll use to setup all servers - local opts = { - on_attach = on_attach, - capabilities = capabilities, - } - - if enhance_server_opts[server.name] then - -- Enhance the default opts with the server-specific ones - enhance_server_opts[server.name](opts) - end - - server:setup(opts) -end) From 1bd3ea5adc5ecf376fb31b8dd2fbff2061d3b7de Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 8 Jun 2022 10:29:35 +0200 Subject: [PATCH 47/52] [nvim] fix: consistent names for diagnostics --- .config/nvim/lua/globals.lua | 2 +- .config/nvim/lua/statusline.lua | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.config/nvim/lua/globals.lua b/.config/nvim/lua/globals.lua index c19c6c3..88f0fff 100644 --- a/.config/nvim/lua/globals.lua +++ b/.config/nvim/lua/globals.lua @@ -8,7 +8,7 @@ local M = {} -- The module to export M = { -- misc sign_error = "", - sign_warning = "", + sign_warn = "", sign_hint = "", sign_info = "", } diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua index 6d21c4e..e7207b4 100644 --- a/.config/nvim/lua/statusline.lua +++ b/.config/nvim/lua/statusline.lua @@ -102,10 +102,10 @@ end local function get_lsp_diagnostics() local result = {} local levels = { - errors = "Error", - warnings = "Warn", + error = "Error", + warn = "Warn", info = "Info", - hints = "Hint" + hint = "Hint" } for k, level in pairs(levels) do @@ -152,12 +152,12 @@ local left = table.concat { { process_diagnostics( globals.sign_error .. " ", - diagnostics.errors, + diagnostics.error, "%#DiagnosticVirtualTextError#" ), process_diagnostics( - globals.sign_warning .. " ", - diagnostics.warnings, + globals.sign_warn .. " ", + diagnostics.warn, "%#DiagnosticVirtualTextWarn#" ), process_diagnostics( From 72d94850b41e334082031e0d12c22577b45f5ffd Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sat, 11 Jun 2022 12:24:01 +0200 Subject: [PATCH 48/52] [statusbar] feat: handle >100% battery cases --- .local/bin/statusbar/sb-battery | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 82a5f32..f0b9fe2 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -42,18 +42,22 @@ do status=" " && capacity="FULL" printf " %s:%s(%s) " "$slot" "$status" "$capacity" else - if [ "$status" = "Charging" ]; then - status="" + if [ 100 -lt $(expr $capacity) ]; then + status="" else - case "$capacity" in - 100|[8-9][0-9]) status="" ;; - [6-7][0-9]) status="" ;; - [4-5][0-9]) status="" ;; - [2-3][0-9]) status="" ;; - *) status="" ;; - esac - [ "BAT0" = $slot ] && [ 30 -gt $capacity ] && notify; + if [ "$status" = "Charging" ]; then + status="" + else + case "$capacity" in + 100|[8-9][0-9]) status="" ;; + [6-7][0-9]) status="" ;; + [4-5][0-9]) status="" ;; + [2-3][0-9]) status="" ;; + *) status="" ;; + esac + [ "BAT0" = $slot ] && [ 30 -gt $capacity ] && notify; + fi + printf " %s:%s (%0.2d%%) " "$slot" "$status" "$capacity"; fi - printf " %s:%s (%0.2d%%) " "$slot" "$status" "$capacity"; fi done From a035e1ee1755fd719792446ab920117c4a4670ae Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 8 Jul 2022 15:24:58 +0200 Subject: [PATCH 49/52] [nvim] feat: tweak autocomplete behavior change binding autocomplete --- .config/nvim/lua/plugin/cmp.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index c12ce81..e53c879 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -48,7 +48,7 @@ local icons = { cmp.setup { completion = { - autocomplete = false + autocomplete = true }, sources = { { name = "path" }, @@ -91,21 +91,31 @@ cmp.setup { select = true, }), [""] = cmp.mapping(function(fallback) + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() elseif has_words_before() then cmp.complete() else fallback() end end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) else fallback() end From dede9bcf793ac8e6004cdde1f4034b8869f4c966 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Fri, 8 Jul 2022 15:26:05 +0200 Subject: [PATCH 50/52] [scripts] feat: compile main.tex the right way --- .local/bin/compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/compiler b/.local/bin/compiler index e9eeb94..8bdbef8 100755 --- a/.local/bin/compiler +++ b/.local/bin/compiler @@ -31,7 +31,7 @@ shebangtest() } texcompile() { \ - [ -e "main.tex" ] && base="main" && file="$base.tex" + [ "$base" != "notes" ] && [ -e "main.tex" ] && base="main" && file="$base.tex" cmd="pdflatex" case "$(head -n 1 $file)" in *lua*) cmd="lualatex" ;; From 4540ec557838d46027144cf989f40b29f0488f1e Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Thu, 28 Jul 2022 20:06:24 +0200 Subject: [PATCH 51/52] [mail] feat: add MOVEP/QEST folders to ens account --- .config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc b/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc index bb594ad..32d74f4 100644 --- a/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc +++ b/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc @@ -23,7 +23,7 @@ set signature="/home/swytch/.config/mutt/accounts/ens.signature" unmacro index o macro index o "mailsync" "run mbsync to sync david.julien@ens-lyon.fr" -mailboxes "=Sent" "=Drafts" "=Trash" "=INBOX" "=internship" "=fanfare" +mailboxes "=Sent" "=Drafts" "=Trash" "=INBOX" "=internship" "=MOVEP" "=QEST" "=fanfare" set record = "+Sent" macro index,pager gs "=Sent" "go to sent" macro index,pager Ms ";=Sent" "move mail to sent" @@ -46,3 +46,9 @@ macro index,pager Cf ";=fanfare" "copy mail to fanfare" macro index,pager gI "=internship" "go to internship" macro index,pager MI ";=internship" "move mail to internship" macro index,pager CI ";=internship" "copy mail to internship" +macro index,pager gm "=MOVEP" "go to MOVEP" +macro index,pager Mm ";=MOVEP" "move mail to MOVEP" +macro index,pager Cm ";=MOVEP" "copy mail to MOVEP" +macro index,pager gq "=QEST" "go to QEST" +macro index,pager Mq ";=QEST" "move mail to QEST" +macro index,pager Cq ";=QEST" "copy mail to QEST" From 40a6eb6330b47872b0bcaec58dec9eac361b860a Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Thu, 28 Jul 2022 20:06:53 +0200 Subject: [PATCH 52/52] [statusbar] feat: separate states for wifi down and no ssid --- .local/bin/statusbar/sb-internet | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet index def21ed..dbe07c8 100755 --- a/.local/bin/statusbar/sb-internet +++ b/.local/bin/statusbar/sb-internet @@ -13,7 +13,11 @@ # Wifi quality percentage and  icon if ethernet is connected. ssid="$(wpa_cli status | grep -i ^ssid | sed -e 's/.*=//')" state="$(wpa_cli status | grep -i ^wpa_state | sed -e 's/.*=//')" -[ "COMPLETED" = $state ] && str="$(printf " %s" $ssid)" || str="$(printf " ---")" +case "$state" in + COMPLETED) str="$(printf " %s" $ssid)" ;; + INTERFACE_DISABLED) str="WIFI DOWN" ;; + *) str="$(printf "NO WIFI")";; +esac eth="$(cat /sys/class/net/enp0s31f6/operstate)" if [ "up" = "$eth" ]; then str="$(printf "%s /  " "$str")"