diff --git a/.config/nvim/after/ftplugin/groff.vim b/.config/.old/nvim_0.4.4/after/ftplugin/groff.vim similarity index 100% rename from .config/nvim/after/ftplugin/groff.vim rename to .config/.old/nvim_0.4.4/after/ftplugin/groff.vim diff --git a/.config/nvim/after/ftplugin/python.vim b/.config/.old/nvim_0.4.4/after/ftplugin/python.vim similarity index 100% rename from .config/nvim/after/ftplugin/python.vim rename to .config/.old/nvim_0.4.4/after/ftplugin/python.vim diff --git a/.config/nvim/after/ftplugin/tex.vim b/.config/.old/nvim_0.4.4/after/ftplugin/tex.vim similarity index 100% rename from .config/nvim/after/ftplugin/tex.vim rename to .config/.old/nvim_0.4.4/after/ftplugin/tex.vim diff --git a/.config/nvim/after/ftplugin/text.vim b/.config/.old/nvim_0.4.4/after/ftplugin/text.vim similarity index 100% rename from .config/nvim/after/ftplugin/text.vim rename to .config/.old/nvim_0.4.4/after/ftplugin/text.vim diff --git a/.config/nvim/after/ftplugin/verilog.vim b/.config/.old/nvim_0.4.4/after/ftplugin/verilog.vim similarity index 100% rename from .config/nvim/after/ftplugin/verilog.vim rename to .config/.old/nvim_0.4.4/after/ftplugin/verilog.vim diff --git a/.config/nvim/init.vim b/.config/.old/nvim_0.4.4/init.vim similarity index 100% rename from .config/nvim/init.vim rename to .config/.old/nvim_0.4.4/init.vim diff --git a/.config/nvim/spell/fr.utf-8.add b/.config/.old/nvim_0.4.4/spell/fr.utf-8.add similarity index 100% rename from .config/nvim/spell/fr.utf-8.add rename to .config/.old/nvim_0.4.4/spell/fr.utf-8.add diff --git a/.config/nvim/statusline.vim b/.config/.old/nvim_0.4.4/statusline.vim similarity index 100% rename from .config/nvim/statusline.vim rename to .config/.old/nvim_0.4.4/statusline.vim diff --git a/.config/nvim/templates/c.template b/.config/.old/nvim_0.4.4/templates/c.template similarity index 100% rename from .config/nvim/templates/c.template rename to .config/.old/nvim_0.4.4/templates/c.template diff --git a/.config/nvim/templates/cpp.template b/.config/.old/nvim_0.4.4/templates/cpp.template similarity index 100% rename from .config/nvim/templates/cpp.template rename to .config/.old/nvim_0.4.4/templates/cpp.template diff --git a/.config/nvim/templates/h.template b/.config/.old/nvim_0.4.4/templates/h.template similarity index 100% rename from .config/nvim/templates/h.template rename to .config/.old/nvim_0.4.4/templates/h.template diff --git a/.config/nvim/templates/hpp.template b/.config/.old/nvim_0.4.4/templates/hpp.template similarity index 100% rename from .config/nvim/templates/hpp.template rename to .config/.old/nvim_0.4.4/templates/hpp.template diff --git a/.config/nvim/templates/main.c.template b/.config/.old/nvim_0.4.4/templates/main.c.template similarity index 100% rename from .config/nvim/templates/main.c.template rename to .config/.old/nvim_0.4.4/templates/main.c.template diff --git a/.config/nvim/templates/main.cpp.template b/.config/.old/nvim_0.4.4/templates/main.cpp.template similarity index 100% rename from .config/nvim/templates/main.cpp.template rename to .config/.old/nvim_0.4.4/templates/main.cpp.template diff --git a/.config/nvim/templates/makefile.template b/.config/.old/nvim_0.4.4/templates/makefile.template similarity index 100% rename from .config/nvim/templates/makefile.template rename to .config/.old/nvim_0.4.4/templates/makefile.template diff --git a/.config/nvim/templates/py.template b/.config/.old/nvim_0.4.4/templates/py.template similarity index 100% rename from .config/nvim/templates/py.template rename to .config/.old/nvim_0.4.4/templates/py.template diff --git a/.config/nvim/templates/sh.template b/.config/.old/nvim_0.4.4/templates/sh.template similarity index 100% rename from .config/nvim/templates/sh.template rename to .config/.old/nvim_0.4.4/templates/sh.template diff --git a/.config/nvim/templates/vim.template b/.config/.old/nvim_0.4.4/templates/vim.template similarity index 100% rename from .config/nvim/templates/vim.template rename to .config/.old/nvim_0.4.4/templates/vim.template diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..39ff15b --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,11 @@ +-- Author : swytch +-- Created : Friday Mar 12, 2021 17:42:34 CET +-- License : GPLv3 +-- Description : neovim configuration file + +require("settings") -- ./lua/settings.lua +require("plugins") -- ./lua/plugins.lua +require("maps") -- ./lua/maps.lua +require("statusline") -- ./lua/statusline.lua + +require("polyjuice") -- colorscheme diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua new file mode 100644 index 0000000..293d617 --- /dev/null +++ b/.config/nvim/lua/maps.lua @@ -0,0 +1,15 @@ +-- Author : swytch +-- Created : Friday Mar 12, 2021 20:17:19 CET +-- License : GPLv3 +-- Description : neovim mappings file + +utils = require("utils") + +utils.map("n", "", "") +utils.map("n", "j", "bn") +utils.map("n", "k", "bp") +utils.map("n", "y", "\"+y") +utils.map("v", "p", "\"+P") +utils.map("n", "", "w! | !compiler %") +utils.map("n", "s", "PackerSync") +utils.map("n", "c", "ColorizerToggle") diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..1681c51 --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,45 @@ +-- Author : swytch +-- Created : Friday Mar 12, 2021 22:28:34 CET +-- License : GPLv3 +-- 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" +end + +return require("packer").startup(function() + -- packer manages itself + use "wbthomason/packer.nvim" + + -- colorscheme + use { + "~/.local/src/polyjuice/", + requires = "tjdevries/colorbuddy.nvim" + } + + -- tree-sitter + use "nvim-treesitter/nvim-treesitter" + + -- fuzzy finder + use { + "nvim-telescope/telescope.nvim", + requires = {{"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"}}, + opt = true, + cmd = {"Telescope"} + } + + -- display colors directly in editor + use { + "norcalli/nvim-colorizer.lua", + opt = true, + cmd = {"ColorizerToggle"} + } + +end) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua new file mode 100644 index 0000000..fd277bb --- /dev/null +++ b/.config/nvim/lua/settings.lua @@ -0,0 +1,66 @@ +-- Author : swytch +-- Created : Friday Mar 12, 2021 17:43:21 CET +-- License : GPLv3 +-- Description : neovim settings file + +utils = require("utils") + +local g = vim.g + +local o = vim.o +local w = vim.wo +local b = vim.bo + +-- general +o.wildignore = [[ + .git + *.o,*.class + *.jpg,*.jpeg,*.png + *.avi,*.mp4,*.mkv + *.mp3,*.ogg,*.flac + *.eot,*.otf,*.ttf,*.woff + *.pdf + *.zip,*.gz,*.rar,*.tar.xz +]] +o.wildmode = "longest,full" +o.wildoptions = "pum" +o.clipboard = "unnamedplus" +g.netrw_dirhistmax = 0 + +-- editor +o.splitright = true +o.splitbelow = true +o.scrolloff = 4 +o.termguicolors = true +o.background = "dark" +o.shortmess = o.shortmess .. "c" +w.number = true +w.relativenumber = true +o.listchars = "tab:<->,nbsp:␣,trail:·,extends:>,precedes:<" +o.showmatch = true +o.ignorecase = true +o.smartcase = true +o.inccommand = "split" +o.completeopt = "menuone,noinsert,noselect" + +-- statusline +o.laststatus = 2 +o.showmode = false + +-- text, tabs, indents +b.textwidth = 79 +b.shiftwidth = 8 +b.softtabstop = -1 +b.expandtab = true +b.shiftwidth = 0 +o.backspace = "indent,eol,start" +o.cindent = true + +-- augroups +utils.create_augroup({ + {"BufWritePre", "*", "%s/\\s\\+$//e"} +}, "remove_trailing_whitespaces") +utils.create_augroup({ + {"BufNewFile,BufRead", "*.mom", "set filetype=groff"}, + {"BufNewFile,BufRead", "*.tex", "set filetype=tex"}, +}, "enforce_filetypes") diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua new file mode 100644 index 0000000..fbbc633 --- /dev/null +++ b/.config/nvim/lua/statusline.lua @@ -0,0 +1,203 @@ +-- Author : swytch +-- Created : Friday Mar 12, 2021 21:45:21 CET +-- License : GPLv3 +-- Description : neovim statusline file +-- based on github/nihilistkitten's work + + +local function gen_section(hl_string, items) + 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" +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] +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] +end + +-- don't return a filename that's too long +local function filename() + if vim.api.nvim_win_get_width(0) > 80 then + return "%F" + else + return "%t" + end +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 = "Warning", + info = "Information", + hints = "Hint" + } + + for k, level in pairs(levels) do + result[k] = vim.lsp.diagnostic.get_count(bufnr, level) + end + + return result +end + +local function process_diagnostics(prefix, n, hl) + if n > 0 then + return hl .. prefix .. n + else + return "" + end +end + +local function spell_check() + if vim.wo.spell then + 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 left = table.concat { + gen_section("%#Buffer#", {"[%n]"}), + gen_section(accent_color, {get_mode_display_name(mg)}), + gen_section("%#Middle#", {filename()}), + gen_section("%#Bottom#", {"%m", "%r"}), + gen_section( + "%#Alert#", + { + process_diagnostics("E:", diagnostics.errors, "%#LspDiagnosticsDefaultError#"), + process_diagnostics("W:", diagnostics.warnings, "%#LspDiagnosticsDefaultWarning#"), + process_diagnostics("I:", diagnostics.info, "%#LspDiagnosticsDefaultInformation#") + } + ) + } + 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 + } + +end + +local function statusline_not_focused() + return table.concat { + gen_section("%#StatuslineNF#", {"[%n]"}), + gen_section("%#StatuslineNF#", {filename(), "%m"}), + "%=", + gen_section("%#StatuslineNF#", {"%03.p%%"}), + gen_section("%#StatuslineNF#", {"-%03.c-"}) + } +end + +function gen_statusline() + 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()\")" diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua new file mode 100644 index 0000000..7fbb87a --- /dev/null +++ b/.config/nvim/lua/utils.lua @@ -0,0 +1,34 @@ +-- Author : swytch +-- Created : Friday Mar 12, 2021 20:07:39 CET +-- License : GPLv3 +-- Description : neovim utils file + +local M = {} -- The module to export +local cmd = vim.cmd + +-- augroup helper +function M.create_augroup(autocmds, name) + cmd("augroup " .. name) + cmd("autocmd!") + for _, autocmd in ipairs(autocmds) do + cmd("autocmd " .. table.concat(autocmd, " ")) + end + cmd("augroup END") +end + +-- add a path to the rtp +function M.add_rtp(path) + local rtp = vim.o.rtp + 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 + +-- Make it accessible everywhere +_G.utils = M +-- Export the module +return M diff --git a/.config/paru/pkglist.txt b/.config/paru/pkglist.txt index f12db19..dc07de0 100644 --- a/.config/paru/pkglist.txt +++ b/.config/paru/pkglist.txt @@ -16,6 +16,7 @@ binutils bison capitaine-cursors cdparanoia +cmake cronie dash dunst @@ -53,7 +54,7 @@ mpv msmtp ncmpcpp neomutt -neovim +ninja nnn notmuch openvpn @@ -80,6 +81,7 @@ texinfo texlive-core texlive-latexextra transmission-cli +tree-sitter tremc ttf-dejavu ttf-fira-sans