From 5db8c17379320595160bd06e0eaa44e32ce1c123 Mon Sep 17 00:00:00 2001 From: don philipe Date: Sat, 30 Nov 2024 13:42:58 +0100 Subject: [PATCH 1/3] Fix deprecated alacritty config --- .config/alacritty/alacritty.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/alacritty/alacritty.toml b/.config/alacritty/alacritty.toml index 2fa0f34..e3a802c 100644 --- a/.config/alacritty/alacritty.toml +++ b/.config/alacritty/alacritty.toml @@ -1,6 +1,6 @@ # https://github.com/alacritty/alacritty-theme -import = ["~/.config/alacritty/themes/themes/gruvbox_dark.toml"] -shell = "/bin/zsh" +general.import = ["~/.config/alacritty/themes/themes/gruvbox_dark.toml"] +terminal.shell = "/bin/zsh" [colors.cursor] cursor = "#00ff00" From f303f1aa1df99d7a91650f9ba7e11f4156ae125e Mon Sep 17 00:00:00 2001 From: don philipe Date: Fri, 3 Jan 2025 15:16:10 +0100 Subject: [PATCH 2/3] Avoid logging space prefixed commands to hist file like qrcode --- .zsh-custom/functions.zsh | 4 +++- .zshrc | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.zsh-custom/functions.zsh b/.zsh-custom/functions.zsh index 224e35b..a3fa96b 100644 --- a/.zsh-custom/functions.zsh +++ b/.zsh-custom/functions.zsh @@ -39,10 +39,12 @@ startx() } # generate qrcode and display it -qrcode() +func_qrcode() { qrencode "$1" -o - | feh - } +# Create alias calling the function with space prefix, so that it is not logged in history file. This avoids logging passwords and stuff. +alias qrcode=" func_qrcode" ogg2mp3() { diff --git a/.zshrc b/.zshrc index 67f59db..5754a3b 100644 --- a/.zshrc +++ b/.zshrc @@ -82,6 +82,7 @@ source $ZSH/oh-my-zsh.sh setopt appendhistory autocd extendedglob setopt GLOB_COMPLETE +setopt HIST_IGNORE_SPACE # ignore command lines when first character is a space unsetopt beep ### Enter Vim-Mode ### From 01ce55d1077ba679f6fa403867c819253beaba2d Mon Sep 17 00:00:00 2001 From: don philipe Date: Wed, 22 Jan 2025 22:29:58 +0100 Subject: [PATCH 3/3] Add neovim config with some plugins --- .config/nvim/init.lua | 12 ++++++++ .config/nvim/lua/config/cmp.lua | 27 ++++++++++++++++++ .config/nvim/lua/config/lazy.lua | 38 +++++++++++++++++++++++++ .config/nvim/lua/config/lsp.lua | 32 +++++++++++++++++++++ .config/nvim/lua/config/mason.lua | 9 ++++++ .config/nvim/lua/config/remap.lua | 16 +++++++++++ .config/nvim/lua/config/set.lua | 13 +++++++++ .config/nvim/lua/config/treesitter.lua | 37 ++++++++++++++++++++++++ .config/nvim/lua/plugins/cmp.lua | 3 ++ .config/nvim/lua/plugins/gen.lua | 13 +++++++++ .config/nvim/lua/plugins/gruvbox.lua | 3 ++ .config/nvim/lua/plugins/lsp.lua | 5 ++++ .config/nvim/lua/plugins/mason.lua | 6 ++++ .config/nvim/lua/plugins/mini.lua | 9 ++++++ .config/nvim/lua/plugins/treesitter.lua | 5 ++++ 15 files changed, 228 insertions(+) create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lua/config/cmp.lua create mode 100644 .config/nvim/lua/config/lazy.lua create mode 100644 .config/nvim/lua/config/lsp.lua create mode 100644 .config/nvim/lua/config/mason.lua create mode 100644 .config/nvim/lua/config/remap.lua create mode 100644 .config/nvim/lua/config/set.lua create mode 100644 .config/nvim/lua/config/treesitter.lua create mode 100644 .config/nvim/lua/plugins/cmp.lua create mode 100644 .config/nvim/lua/plugins/gen.lua create mode 100644 .config/nvim/lua/plugins/gruvbox.lua create mode 100644 .config/nvim/lua/plugins/lsp.lua create mode 100644 .config/nvim/lua/plugins/mason.lua create mode 100644 .config/nvim/lua/plugins/mini.lua create mode 100644 .config/nvim/lua/plugins/treesitter.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..efa83f5 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,12 @@ +require("config.remap") +require("config.set") + +-- plugin manager +require("config.lazy") + +-- plugins +require("config.cmp") +require("config.gen-private") +require("config.lsp") +require("config.mason") +require("config.treesitter") diff --git a/.config/nvim/lua/config/cmp.lua b/.config/nvim/lua/config/cmp.lua new file mode 100644 index 0000000..16affed --- /dev/null +++ b/.config/nvim/lua/config/cmp.lua @@ -0,0 +1,27 @@ +-- autocompletion +local cmp = require('cmp') +cmp.setup({ + sources = { + {name = 'nvim_lsp'}, + }, + mapping = cmp.mapping.preset.insert({ + -- Navigate between completion items + [''] = cmp.mapping.select_prev_item({behavior = 'select'}), + [''] = cmp.mapping.select_next_item({behavior = 'select'}), + + -- `Enter` key to confirm completion + [''] = cmp.mapping.confirm({select = false}), + + -- Ctrl+Space to trigger completion menu + [''] = cmp.mapping.complete(), + + -- Scroll up and down in the completion documentation + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + }), + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, +}) diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..349ff4d --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,38 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, + true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) + +-- Open lazy menu with :Lazy check diff --git a/.config/nvim/lua/config/lsp.lua b/.config/nvim/lua/config/lsp.lua new file mode 100644 index 0000000..b4bc2f4 --- /dev/null +++ b/.config/nvim/lua/config/lsp.lua @@ -0,0 +1,32 @@ +-- Reserve a space in the gutter +-- This will avoid an annoying layout shift in the screen +vim.opt.signcolumn = 'yes' + +-- Add cmp_nvim_lsp capabilities settings to lspconfig +-- This should be executed before you configure any language server +local lspconfig_defaults = require('lspconfig').util.default_config +lspconfig_defaults.capabilities = vim.tbl_deep_extend( + 'force', + lspconfig_defaults.capabilities, + require('cmp_nvim_lsp').default_capabilities() +) + +-- This is where you enable features that only work +-- if there is a language server active in the file +vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function(event) + local opts = {buffer = event.buf} + + vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.keymap.set('n', 'go', 'lua vim.lsp.buf.type_definition()', opts) + vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.keymap.set('n', 'gs', 'lua vim.lsp.buf.signature_help()', opts) + vim.keymap.set('n', '', 'lua vim.lsp.buf.rename()', opts) + vim.keymap.set({'n', 'x'}, '', 'lua vim.lsp.buf.format({async = true})', opts) + vim.keymap.set('n', '', 'lua vim.lsp.buf.code_action()', opts) + end, +}) diff --git a/.config/nvim/lua/config/mason.lua b/.config/nvim/lua/config/mason.lua new file mode 100644 index 0000000..a1cdf00 --- /dev/null +++ b/.config/nvim/lua/config/mason.lua @@ -0,0 +1,9 @@ +require('mason').setup({}) +require('mason-lspconfig').setup({ + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + }, +}) +-- install language servers via :LspInstall diff --git a/.config/nvim/lua/config/remap.lua b/.config/nvim/lua/config/remap.lua new file mode 100644 index 0000000..038ed82 --- /dev/null +++ b/.config/nvim/lua/config/remap.lua @@ -0,0 +1,16 @@ +-- Custom remappings + +-- paste buffer and dont replace buffer content with what has been pasted over (but put it to "void" buffer) +vim.keymap.set("x", "p", "\"_dP") + +-- tab creation, navigation and closing +vim.keymap.set("n", "", ":tabnew") +vim.keymap.set("n", "", ":tabprevious") +vim.keymap.set("n", "", ":tabnext") +vim.keymap.set("n", "", ":tabclose") + +-- resize windows with arrow keys +vim.keymap.set("n", "", ":resize -1") +vim.keymap.set("n", "", ":resize +1") +vim.keymap.set("n", "", ":vertical resize -1") +vim.keymap.set("n", "", ":vertical resize +1") diff --git a/.config/nvim/lua/config/set.lua b/.config/nvim/lua/config/set.lua new file mode 100644 index 0000000..7edec9c --- /dev/null +++ b/.config/nvim/lua/config/set.lua @@ -0,0 +1,13 @@ +-- Custom settings + +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.scrolloff = 8 + +vim.opt.incsearch = true + +vim.opt.signcolumn = "yes" + diff --git a/.config/nvim/lua/config/treesitter.lua b/.config/nvim/lua/config/treesitter.lua new file mode 100644 index 0000000..3ba99be --- /dev/null +++ b/.config/nvim/lua/config/treesitter.lua @@ -0,0 +1,37 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the listed parsers MUST always be installed) + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "python", "javascript", "css", "html", "yaml", "java", "bash", "csv", "dockerfile", "htmldjango", "json", "nginx" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (or "all") + --ignore_install = { "javascript" }, + + highlight = { + enable = true, + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + --disable = { "c", "rust" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + --disable = function(lang, buf) + -- local max_filesize = 100 * 1024 -- 100 KB + -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + -- if ok and stats and stats.size > max_filesize then + -- return true + -- end + --end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..277831d --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,3 @@ +return { + {'neovim/nvim-cmp'} +} diff --git a/.config/nvim/lua/plugins/gen.lua b/.config/nvim/lua/plugins/gen.lua new file mode 100644 index 0000000..393eff1 --- /dev/null +++ b/.config/nvim/lua/plugins/gen.lua @@ -0,0 +1,13 @@ +local ok, vars = pcall(require, 'config.gen-private') +if not ok then + print("Missing gen-private configuration file.") +end + +return { + { "David-Kunz/gen.nvim", + opts = { + model = vars["model"], + host = vars["host"], + port = vars["port"], + }}, +} diff --git a/.config/nvim/lua/plugins/gruvbox.lua b/.config/nvim/lua/plugins/gruvbox.lua new file mode 100644 index 0000000..4cde366 --- /dev/null +++ b/.config/nvim/lua/plugins/gruvbox.lua @@ -0,0 +1,3 @@ +return { + {'morhetz/gruvbox', config = function() vim.cmd.colorscheme("gruvbox") end } +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..d23fb5c --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,5 @@ +return { + {'neovim/nvim-lspconfig'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/nvim-cmp'}, +} diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..0c448c9 --- /dev/null +++ b/.config/nvim/lua/plugins/mason.lua @@ -0,0 +1,6 @@ +return { + -- mason for downloading language servers + {'williamboman/mason.nvim'}, + -- mason-lspconfig to configure auto setup of language servers + {'williamboman/mason-lspconfig.nvim'}, +} diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..cffe7ae --- /dev/null +++ b/.config/nvim/lua/plugins/mini.lua @@ -0,0 +1,9 @@ +-- plugins form the "mini" plugin set https://github.com/echasnovski/mini.nvim?tab=readme-ov-file#modules +return { + -- auto-insert closing brackets etc. + { + 'echasnovski/mini.pairs', + event = 'InsertEnter', -- lazy loading (when entering insert mode) + config = true, -- shorthand for calling plugins setup function + }, +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..9dc7a85 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,5 @@ +return { + {'nvim-treesitter/nvim-treesitter'} + -- configure parsers via config/treesitter.lua + -- update parsers with :TSUpdate +}