From 00e7848ced11f6c87fd680c7db16dcfe8a77f206 Mon Sep 17 00:00:00 2001 From: bain Date: Thu, 30 Jan 2025 12:15:13 +0100 Subject: [PATCH] update --- nvim/.config/nvim/init.lua | 186 ++++++++++++++++++++++++------- nvim/.config/nvim/lazy-lock.json | 57 +++++----- tmux/.config/tmux/tmux.conf | 1 + zsh/.zshrc | 19 ++-- 4 files changed, 189 insertions(+), 74 deletions(-) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 9642303..1c0e4dd 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -95,7 +95,7 @@ require("lazy").setup({ -- mapping query_strings to modes. selection_modes = { ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise + ['@function.outer'] = 'V', -- linewise ['@class.outer'] = '', -- blockwise }, -- If you set this to `true` (default is `false`) then any textobject is @@ -154,12 +154,14 @@ require("lazy").setup({ -- {{{ LSP config local lsp = require('lsp-zero').preset({}) - local typst_lsp = require'lspconfig'.typst_lsp - if typst_lsp ~= nil then - typst_lsp.setup{ + local tinymist = require 'lspconfig'.tinymist + if tinymist ~= nil then + tinymist.setup { settings = { - exportPdf = "never" -- Choose onType, onSave or never. - } + exportPdf = "never", -- Choose onType, onSave or never. + rootDir = "-", + }, + single_file_support = true, } end @@ -183,12 +185,37 @@ require("lazy").setup({ cmp.setup({ mapping = { - [''] = cmp_action.luasnip_supertab(), - [''] = cmp_action.luasnip_shift_supertab(), - -- Requires the terminal to send proper keycodes (put this in .Xresources): + [''] = cmp.mapping(function(fallback) + local luasnip = require('luasnip') + local col = vim.fn.col('.') - 1 + + if cmp.visible() then + cmp.select_next_item({ behavior = 'select' }) + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + fallback() + else + cmp.complete() + end + end, { 'i', 's' }), + + -- Super shift tab + [''] = cmp.mapping(function(fallback) + local luasnip = require('luasnip') + + if cmp.visible() then + cmp.select_prev_item({ behavior = 'select' }) + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), -- Requires the terminal to send proper keycodes (put this in .Xresources): -- URxvt.keysym.S-Return: \033[13;2u -- URxvt.keysym.C-Return: \033[13;5u [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), }, window = { completion = { @@ -206,24 +233,24 @@ require("lazy").setup({ hint_prefix = "", floating_window = false, }, - config = function(_, opts) require'lsp_signature'.setup(opts) end + config = function(_, opts) require 'lsp_signature'.setup(opts) end }, { 'nvim-telescope/telescope.nvim', tag = '0.1.8', dependencies = { 'nvim-lua/plenary.nvim' }, - config = function () + config = function() local builtin = require('telescope.builtin') local function buffers_autopick() builtin.buffers({ on_complete = { - function(picker) - -- if we have exactly one match, select it - if picker.manager.linked_states.size == 1 then - require("telescope.actions").select_default(picker.prompt_bufnr) - end - end, + function(picker) + -- if we have exactly one match, select it + if picker.manager.linked_states.size == 1 then + require("telescope.actions").select_default(picker.prompt_bufnr) + end + end, } }) end @@ -232,7 +259,7 @@ require("lazy").setup({ vim.keymap.set('n', 'fg', builtin.git_files, {}) vim.keymap.set('n', 'o', buffers_autopick, {}) vim.keymap.set('n', 'st', builtin.live_grep, {}) - vim.keymap.set('n', 'ss', builtin.treesitter, {}) + vim.keymap.set('n', 'ss', builtin.lsp_workspace_symbols, {}) end }, { @@ -253,29 +280,29 @@ require("lazy").setup({ if vim.wo.diff then return ']c' end vim.schedule(function() gs.next_hunk() end) return '' - end, {expr=true}) + end, { expr = true }) map('n', '[c', function() if vim.wo.diff then return '[c' end vim.schedule(function() gs.prev_hunk() end) return '' - end, {expr=true}) + end, { expr = true }) -- Actions map('n', 'gs', gs.stage_hunk) map('n', 'gr', gs.reset_hunk) - map('v', 'gs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) - map('v', 'gr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('v', 'gs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('v', 'gr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end) map('n', 'gu', gs.undo_stage_hunk) map('n', 'gR', gs.reset_buffer) map('n', 'gp', gs.preview_hunk) - map('n', 'gl', function() gs.blame_line{full=true} end) + map('n', 'gl', function() gs.blame_line { full = true } end) map('n', 'gt', gs.toggle_current_line_blame) map('n', 'gj', gs.next_hunk) map('n', 'gk', gs.prev_hunk) -- Text object - map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') end }, -- }}} @@ -297,7 +324,7 @@ require("lazy").setup({ { 'andweeb/presence.nvim', event = 'User EnablePresence', - config = function () + config = function() require("presence").setup({ main_image = "file" }) @@ -308,13 +335,14 @@ require("lazy").setup({ 'tpope/vim-sleuth', }, { - 'https://github.com/github/copilot.vim', + 'zbirenbaum/copilot.lua', cmd = "Copilot", + opts = {}, }, { 'RRethy/vim-illuminate', event = "User EnableIDE", - config = function () + config = function() require('illuminate').configure({ min_count_to_highlight = 3, }) @@ -334,19 +362,20 @@ require("lazy").setup({ } } }, + { 'echasnovski/mini.pairs', version = '*', opts = {} }, { 'tpope/vim-surround' }, { 'echasnovski/mini.hipatterns', version = '*', - config = function () + config = function() local hipatterns = require('mini.hipatterns') hipatterns.setup({ highlighters = { -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE' - fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' }, - hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' }, - todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' }, - note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' }, + fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' }, + hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' }, + todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' }, + note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' }, -- Highlight hex color strings (`#rrggbb`) using that color hex_color = hipatterns.gen_highlighter.hex_color(), @@ -361,7 +390,7 @@ require("lazy").setup({ 'kristijanhusak/vim-dadbod-completion', 'kristijanhusak/vim-dadbod-ui', }, - config = function () + config = function() local cmp = require("cmp") local cmp_action = require('lsp-zero').cmp_action() cmp.setup.filetype({ 'sql' }, { @@ -380,6 +409,76 @@ require("lazy").setup({ }) end }, + { + 'stevearc/conform.nvim', + opts = { + formatters_by_ft = { + python = { "isort", "black" }, + rust = { "rustfmt", lsp_format = "fallback" }, + }, + }, + config = function(_, opts) + require('conform').setup(opts) + vim.api.nvim_create_user_command("Format", function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ["end"] = { args.line2, end_line:len() }, + } + end + require("conform").format({ async = true, lsp_format = "fallback", range = range }) + end, { range = true }) + vim.keymap.set({ "n", "v" }, "F", ":Format") + end + }, + { + "yetone/avante.nvim", + event = "User EnableAvante", + lazy = true, + version = false, -- set this if you want to always pull the latest change + opts = { + provider = "copilot", + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = "make", + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + "zbirenbaum/copilot.lua", -- for providers='copilot' + { + -- support for image pasting + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, + } }) -- }}} -- {{{ Keymap @@ -400,18 +499,21 @@ vim.keymap.set('v', '>', '>gv') vim.keymap.set('n', 'c', ':confirm bdelete') -- copy to system clipboard -vim.keymap.set({"n", "v"}, "y", [["+y]]) -vim.keymap.set({"n", "v"}, "p", [["+p]]) -vim.keymap.set({"n", "v"}, "P", [["+P]]) +vim.keymap.set({ "n", "v" }, "y", [["+y]]) +vim.keymap.set({ "n", "v" }, "p", [["+p]]) +vim.keymap.set({ "n", "v" }, "P", [["+P]]) vim.keymap.set("n", "Y", [["+Y]]) vim.keymap.set("n", "fv", "Ex") vim.keymap.set('n', 'p', function() vim.cmd([[call system("nvr " . expand("%:p") . " && nvr --remote-send \":%bd!|e#|" . line(".") . "zRzz\"")]]) end) + +vim.api.nvim_set_keymap("i", "", "copilot#Accept('')", {expr=true, silent=true}) + -- }}} -- {{{ IDE mode -vim.api.nvim_create_user_command("IDE", function () +vim.api.nvim_create_user_command("IDE", function() vim.api.nvim_exec_autocmds("User", { pattern = "EnableIDE" }) end, {}) if os.getenv("NVIM_IDE_MODE") == "1" then @@ -419,17 +521,21 @@ if os.getenv("NVIM_IDE_MODE") == "1" then end -- }}} +vim.api.nvim_create_user_command("Avante", function() + vim.api.nvim_exec_autocmds("User", { pattern = "EnableAvante" }) +end, {}) + vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { pattern = { "*.eml", "*.mail" }, callback = function(_) vim.cmd("setl tw=80") - vim.cmd("setl fo=awq") + vim.cmd("setl fo=wq") vim.cmd("setl comments+=nb:>") vim.cmd([[match ErrorMsg '\s\+$']]) + vim.cmd([[source ~/email.vim]]) end }) -vim.api.nvim_create_user_command("Presence", function () +vim.api.nvim_create_user_command("Presence", function() vim.api.nvim_exec_autocmds("User", { pattern = "EnablePresence" }) end, {}) - diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 764fea1..96881ef 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,34 +1,41 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "copilot.vim": { "branch": "release", "commit": "0668308e68b0ac28b332b204b469fbe04601536a" }, - "gitsigns.nvim": { "branch": "main", "commit": "39b5b6f48bde0595ce68007ffce408c5d7ac1f79" }, - "lazy.nvim": { "branch": "main", "commit": "cea5920abb202753004440f94ec39bcf2927e02e" }, + "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, + "avante.nvim": { "branch": "main", "commit": "499b7a854be3f5b1ad612b659a1abcf956403b13" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" }, + "copilot.lua": { "branch": "master", "commit": "886ee73b6d464b2b3e3e6a7ff55ce87feac423a9" }, + "dressing.nvim": { "branch": "master", "commit": "56ef6a969a4990d938c5fed40c370f65e125fc97" }, + "gitsigns.nvim": { "branch": "main", "commit": "c6fedfd0b1715ee624384b134becec0a7b0a3d28" }, + "img-clip.nvim": { "branch": "main", "commit": "da61a81872276b75a2971b056da1b849e0c1870b" }, + "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, "lsp-zero.nvim": { "branch": "v2.x", "commit": "9a686513eaaa13d737d0fec8956a18268ead8b29" }, - "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, - "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" }, - "mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" }, - "mini.ai": { "branch": "main", "commit": "a7e90f110e6274262616311b93cef12cd2667a2d" }, - "mini.hipatterns": { "branch": "main", "commit": "427712c754bfdccd8da7073576cd8e2586c0fe93" }, - "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, - "nvim-lspconfig": { "branch": "master", "commit": "cf97d2485fc3f6d4df1b79a3ea183e24c272215e" }, - "nvim-treesitter": { "branch": "master", "commit": "caf275382f91ec8a2498d455c4d7d3fd0265ebd3" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, - "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, - "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "lsp_signature.nvim": { "branch": "master", "commit": "5b64964ed02098c85613ee3d20f96bed1dfb64cc" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.ai": { "branch": "main", "commit": "40e380a589d07ec2c856940c6422aafe5d949a0d" }, + "mini.hipatterns": { "branch": "main", "commit": "fdad87bf545aec5210ca9a2c49fddf6284d72d1e" }, + "mini.pairs": { "branch": "main", "commit": "e543c760edc5e746e5b6cbd02c066c17ead3ef16" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, + "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, + "nvim-lspconfig": { "branch": "master", "commit": "9962e25a23f0e992116b99a9a6400947d5a7177b" }, + "nvim-treesitter": { "branch": "master", "commit": "13f4346876f394973ff676670304a2b734174538" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, + "nvim-web-devicons": { "branch": "master", "commit": "1c9136332840edee0c593f2f4f89598c8ed97f5f" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "render-markdown.nvim": { "branch": "main", "commit": "1ba6fb7998985736ca3480366c9792be05b93ad7" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "tokyodark.nvim": { "branch": "master", "commit": "14bc1b3e596878a10647af7c82de7736300f3322" }, - "typst.vim": { "branch": "main", "commit": "4d18ced62599ffe5b3c0e5e49566d5456121bc02" }, - "vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" }, - "vim-dadbod-completion": { "branch": "master", "commit": "8c9051c1cfc73fcf5bfe9a84db7097e4f7c0180d" }, - "vim-dadbod-ui": { "branch": "master", "commit": "2527310098e7458488e61a528614da142aa2dc42" }, - "vim-fugitive": { "branch": "master", "commit": "d0c1a437536778bcc8174b7cb2ffdf98f611e6fe" }, + "tokyodark.nvim": { "branch": "master", "commit": "cc70a2fb809d5376f2bd8e5836f9bb3f5fb8ef43" }, + "typst.vim": { "branch": "main", "commit": "8ce752f1ba1277046429cb469c17ff2e1abc718f" }, + "vim-dadbod": { "branch": "master", "commit": "9f0ca8bcef704659820a95c3bbd2c262583a66a1" }, + "vim-dadbod-completion": { "branch": "master", "commit": "95cbcf21ea7a5c8c025f387280c2e261b8cb3a89" }, + "vim-dadbod-ui": { "branch": "master", "commit": "65454e2011c029922c2c972d63f8bf04282de033" }, + "vim-fugitive": { "branch": "master", "commit": "d74a7cff4cfcf84f83cc7eccfa365488f3bbabc2" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, - "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" } + "vim-tmux-navigator": { "branch": "master", "commit": "d847ea942a5bb4d4fab6efebc9f30d787fd96e65" } } \ No newline at end of file diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf index 13ad935..c50699e 100644 --- a/tmux/.config/tmux/tmux.conf +++ b/tmux/.config/tmux/tmux.conf @@ -1,4 +1,5 @@ set-option -sa terminal-overrides ",xterm*:Tc" +set -s extended-keys on set -g mouse on set -s escape-time 200 diff --git a/zsh/.zshrc b/zsh/.zshrc index dff2b50..2cb42ef 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -16,15 +16,6 @@ alias ide="NVIM_IDE_MODE=1 nvim" alias gide="ide -c 'set autoindent noexpandtab tabstop=4 shiftwidth=4'" alias showkey="ssh-keygen -y -f" -ffmpeg_compat() { - OUT=$2 - ffmpeg -i "$1" \ - -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p \ - -c:a aac -ac 2 -b:a 128k \ - -movflags faststart \ - "${OUT:-$1.mp4}" -} - on_edit() { echo "Running:" echo " $ $2" @@ -78,3 +69,13 @@ alias cd=z alias pgcli='LESS="-SF" pgcli' command -v bat &>/dev/null && alias cat="bat --plain" + +#export NVM_DIR="$HOME/.config/nvm" +#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +eval "$(fzf --zsh)" + +tw() { + typst watch --open zathura $1 /tmp/temp.pdf +}