This commit is contained in:
bain 2025-01-30 12:15:13 +01:00
parent 7083ad0320
commit 00e7848ced
4 changed files with 189 additions and 74 deletions

View file

@ -154,12 +154,14 @@ require("lazy").setup({
-- {{{ LSP config -- {{{ LSP config
local lsp = require('lsp-zero').preset({}) local lsp = require('lsp-zero').preset({})
local typst_lsp = require'lspconfig'.typst_lsp local tinymist = require 'lspconfig'.tinymist
if typst_lsp ~= nil then if tinymist ~= nil then
typst_lsp.setup{ tinymist.setup {
settings = { settings = {
exportPdf = "never" -- Choose onType, onSave or never. exportPdf = "never", -- Choose onType, onSave or never.
} rootDir = "-",
},
single_file_support = true,
} }
end end
@ -183,12 +185,37 @@ require("lazy").setup({
cmp.setup({ cmp.setup({
mapping = { mapping = {
['<Tab>'] = cmp_action.luasnip_supertab(), ['<Tab>'] = cmp.mapping(function(fallback)
['<S-Tab>'] = cmp_action.luasnip_shift_supertab(), local luasnip = require('luasnip')
-- Requires the terminal to send proper keycodes (put this in .Xresources): 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
['<S-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.S-Return: \033[13;2u
-- URxvt.keysym.C-Return: \033[13;5u -- URxvt.keysym.C-Return: \033[13;5u
['<S-Enter>'] = cmp.mapping.confirm({ select = true }), ['<S-Enter>'] = cmp.mapping.confirm({ select = true }),
['<C-Space>'] = cmp.mapping.complete(),
}, },
window = { window = {
completion = { completion = {
@ -206,13 +233,13 @@ require("lazy").setup({
hint_prefix = "", hint_prefix = "",
floating_window = false, 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', 'nvim-telescope/telescope.nvim',
tag = '0.1.8', tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' }, dependencies = { 'nvim-lua/plenary.nvim' },
config = function () config = function()
local builtin = require('telescope.builtin') local builtin = require('telescope.builtin')
local function buffers_autopick() local function buffers_autopick()
@ -232,7 +259,7 @@ require("lazy").setup({
vim.keymap.set('n', '<leader>fg', builtin.git_files, {}) vim.keymap.set('n', '<leader>fg', builtin.git_files, {})
vim.keymap.set('n', '<leader>o', buffers_autopick, {}) vim.keymap.set('n', '<leader>o', buffers_autopick, {})
vim.keymap.set('n', '<leader>st', builtin.live_grep, {}) vim.keymap.set('n', '<leader>st', builtin.live_grep, {})
vim.keymap.set('n', '<leader>ss', builtin.treesitter, {}) vim.keymap.set('n', '<leader>ss', builtin.lsp_workspace_symbols, {})
end end
}, },
{ {
@ -253,29 +280,29 @@ require("lazy").setup({
if vim.wo.diff then return ']c' end if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end) vim.schedule(function() gs.next_hunk() end)
return '<Ignore>' return '<Ignore>'
end, {expr=true}) end, { expr = true })
map('n', '[c', function() map('n', '[c', function()
if vim.wo.diff then return '[c' end if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end) vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>' return '<Ignore>'
end, {expr=true}) end, { expr = true })
-- Actions -- Actions
map('n', '<leader>gs', gs.stage_hunk) map('n', '<leader>gs', gs.stage_hunk)
map('n', '<leader>gr', gs.reset_hunk) map('n', '<leader>gr', gs.reset_hunk)
map('v', '<leader>gs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) map('v', '<leader>gs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
map('v', '<leader>gr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) map('v', '<leader>gr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
map('n', '<leader>gu', gs.undo_stage_hunk) map('n', '<leader>gu', gs.undo_stage_hunk)
map('n', '<leader>gR', gs.reset_buffer) map('n', '<leader>gR', gs.reset_buffer)
map('n', '<leader>gp', gs.preview_hunk) map('n', '<leader>gp', gs.preview_hunk)
map('n', '<leader>gl', function() gs.blame_line{full=true} end) map('n', '<leader>gl', function() gs.blame_line { full = true } end)
map('n', '<leader>gt', gs.toggle_current_line_blame) map('n', '<leader>gt', gs.toggle_current_line_blame)
map('n', '<leader>gj', gs.next_hunk) map('n', '<leader>gj', gs.next_hunk)
map('n', '<leader>gk', gs.prev_hunk) map('n', '<leader>gk', gs.prev_hunk)
-- Text object -- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>') map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end end
}, },
-- }}} -- }}}
@ -297,7 +324,7 @@ require("lazy").setup({
{ {
'andweeb/presence.nvim', 'andweeb/presence.nvim',
event = 'User EnablePresence', event = 'User EnablePresence',
config = function () config = function()
require("presence").setup({ require("presence").setup({
main_image = "file" main_image = "file"
}) })
@ -308,13 +335,14 @@ require("lazy").setup({
'tpope/vim-sleuth', 'tpope/vim-sleuth',
}, },
{ {
'https://github.com/github/copilot.vim', 'zbirenbaum/copilot.lua',
cmd = "Copilot", cmd = "Copilot",
opts = {},
}, },
{ {
'RRethy/vim-illuminate', 'RRethy/vim-illuminate',
event = "User EnableIDE", event = "User EnableIDE",
config = function () config = function()
require('illuminate').configure({ require('illuminate').configure({
min_count_to_highlight = 3, min_count_to_highlight = 3,
}) })
@ -334,11 +362,12 @@ require("lazy").setup({
} }
} }
}, },
{ 'echasnovski/mini.pairs', version = '*', opts = {} },
{ 'tpope/vim-surround' }, { 'tpope/vim-surround' },
{ {
'echasnovski/mini.hipatterns', 'echasnovski/mini.hipatterns',
version = '*', version = '*',
config = function () config = function()
local hipatterns = require('mini.hipatterns') local hipatterns = require('mini.hipatterns')
hipatterns.setup({ hipatterns.setup({
highlighters = { highlighters = {
@ -361,7 +390,7 @@ require("lazy").setup({
'kristijanhusak/vim-dadbod-completion', 'kristijanhusak/vim-dadbod-completion',
'kristijanhusak/vim-dadbod-ui', 'kristijanhusak/vim-dadbod-ui',
}, },
config = function () config = function()
local cmp = require("cmp") local cmp = require("cmp")
local cmp_action = require('lsp-zero').cmp_action() local cmp_action = require('lsp-zero').cmp_action()
cmp.setup.filetype({ 'sql' }, { cmp.setup.filetype({ 'sql' }, {
@ -380,6 +409,76 @@ require("lazy").setup({
}) })
end 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" }, "<leader>F", ":Format<CR>")
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 -- {{{ Keymap
@ -400,18 +499,21 @@ vim.keymap.set('v', '>', '>gv')
vim.keymap.set('n', '<leader>c', ':confirm bdelete<cr>') vim.keymap.set('n', '<leader>c', ':confirm bdelete<cr>')
-- copy to system clipboard -- copy to system clipboard
vim.keymap.set({"n", "v"}, "<leader>y", [["+y]]) vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
vim.keymap.set({"n", "v"}, "<leader>p", [["+p]]) vim.keymap.set({ "n", "v" }, "<leader>p", [["+p]])
vim.keymap.set({"n", "v"}, "<leader>P", [["+P]]) vim.keymap.set({ "n", "v" }, "<leader>P", [["+P]])
vim.keymap.set("n", "<leader>Y", [["+Y]]) vim.keymap.set("n", "<leader>Y", [["+Y]])
vim.keymap.set("n", "<leader>fv", "<cmd>Ex<cr>") vim.keymap.set("n", "<leader>fv", "<cmd>Ex<cr>")
vim.keymap.set('n', '<C-w>p', function() vim.keymap.set('n', '<C-w>p', function()
vim.cmd([[call system("nvr " . expand("%:p") . " && nvr --remote-send \":%bd!|e#|" . line(".") . "<cr>zRzz\"")]]) vim.cmd([[call system("nvr " . expand("%:p") . " && nvr --remote-send \":%bd!|e#|" . line(".") . "<cr>zRzz\"")]])
end) end)
vim.api.nvim_set_keymap("i", "<C-ú>", "copilot#Accept('<CR>')", {expr=true, silent=true})
-- }}} -- }}}
-- {{{ IDE mode -- {{{ 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" }) vim.api.nvim_exec_autocmds("User", { pattern = "EnableIDE" })
end, {}) end, {})
if os.getenv("NVIM_IDE_MODE") == "1" then if os.getenv("NVIM_IDE_MODE") == "1" then
@ -419,17 +521,21 @@ if os.getenv("NVIM_IDE_MODE") == "1" then
end 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" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.eml", "*.mail" }, pattern = { "*.eml", "*.mail" },
callback = function(_) callback = function(_)
vim.cmd("setl tw=80") vim.cmd("setl tw=80")
vim.cmd("setl fo=awq") vim.cmd("setl fo=wq")
vim.cmd("setl comments+=nb:>") vim.cmd("setl comments+=nb:>")
vim.cmd([[match ErrorMsg '\s\+$']]) vim.cmd([[match ErrorMsg '\s\+$']])
vim.cmd([[source ~/email.vim]])
end 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" }) vim.api.nvim_exec_autocmds("User", { pattern = "EnablePresence" })
end, {}) end, {})

View file

@ -1,34 +1,41 @@
{ {
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "avante.nvim": { "branch": "main", "commit": "499b7a854be3f5b1ad612b659a1abcf956403b13" },
"copilot.vim": { "branch": "release", "commit": "0668308e68b0ac28b332b204b469fbe04601536a" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"gitsigns.nvim": { "branch": "main", "commit": "39b5b6f48bde0595ce68007ffce408c5d7ac1f79" }, "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" },
"lazy.nvim": { "branch": "main", "commit": "cea5920abb202753004440f94ec39bcf2927e02e" }, "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-zero.nvim": { "branch": "v2.x", "commit": "9a686513eaaa13d737d0fec8956a18268ead8b29" },
"lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, "lsp_signature.nvim": { "branch": "master", "commit": "5b64964ed02098c85613ee3d20f96bed1dfb64cc" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" },
"mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.ai": { "branch": "main", "commit": "a7e90f110e6274262616311b93cef12cd2667a2d" }, "mini.ai": { "branch": "main", "commit": "40e380a589d07ec2c856940c6422aafe5d949a0d" },
"mini.hipatterns": { "branch": "main", "commit": "427712c754bfdccd8da7073576cd8e2586c0fe93" }, "mini.hipatterns": { "branch": "main", "commit": "fdad87bf545aec5210ca9a2c49fddf6284d72d1e" },
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, "mini.pairs": { "branch": "main", "commit": "e543c760edc5e746e5b6cbd02c066c17ead3ef16" },
"nvim-lspconfig": { "branch": "master", "commit": "cf97d2485fc3f6d4df1b79a3ea183e24c272215e" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-treesitter": { "branch": "master", "commit": "caf275382f91ec8a2498d455c4d7d3fd0265ebd3" }, "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-lspconfig": { "branch": "master", "commit": "9962e25a23f0e992116b99a9a6400947d5a7177b" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, "nvim-treesitter": { "branch": "master", "commit": "13f4346876f394973ff676670304a2b734174538" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "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" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" },
"render-markdown.nvim": { "branch": "main", "commit": "1ba6fb7998985736ca3480366c9792be05b93ad7" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"tokyodark.nvim": { "branch": "master", "commit": "14bc1b3e596878a10647af7c82de7736300f3322" }, "tokyodark.nvim": { "branch": "master", "commit": "cc70a2fb809d5376f2bd8e5836f9bb3f5fb8ef43" },
"typst.vim": { "branch": "main", "commit": "4d18ced62599ffe5b3c0e5e49566d5456121bc02" }, "typst.vim": { "branch": "main", "commit": "8ce752f1ba1277046429cb469c17ff2e1abc718f" },
"vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" }, "vim-dadbod": { "branch": "master", "commit": "9f0ca8bcef704659820a95c3bbd2c262583a66a1" },
"vim-dadbod-completion": { "branch": "master", "commit": "8c9051c1cfc73fcf5bfe9a84db7097e4f7c0180d" }, "vim-dadbod-completion": { "branch": "master", "commit": "95cbcf21ea7a5c8c025f387280c2e261b8cb3a89" },
"vim-dadbod-ui": { "branch": "master", "commit": "2527310098e7458488e61a528614da142aa2dc42" }, "vim-dadbod-ui": { "branch": "master", "commit": "65454e2011c029922c2c972d63f8bf04282de033" },
"vim-fugitive": { "branch": "master", "commit": "d0c1a437536778bcc8174b7cb2ffdf98f611e6fe" }, "vim-fugitive": { "branch": "master", "commit": "d74a7cff4cfcf84f83cc7eccfa365488f3bbabc2" },
"vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" },
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "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-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" } "vim-tmux-navigator": { "branch": "master", "commit": "d847ea942a5bb4d4fab6efebc9f30d787fd96e65" }
} }

View file

@ -1,4 +1,5 @@
set-option -sa terminal-overrides ",xterm*:Tc" set-option -sa terminal-overrides ",xterm*:Tc"
set -s extended-keys on
set -g mouse on set -g mouse on
set -s escape-time 200 set -s escape-time 200

View file

@ -16,15 +16,6 @@ alias ide="NVIM_IDE_MODE=1 nvim"
alias gide="ide -c 'set autoindent noexpandtab tabstop=4 shiftwidth=4'" alias gide="ide -c 'set autoindent noexpandtab tabstop=4 shiftwidth=4'"
alias showkey="ssh-keygen -y -f" 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() { on_edit() {
echo "Running:" echo "Running:"
echo " $ $2" echo " $ $2"
@ -78,3 +69,13 @@ alias cd=z
alias pgcli='LESS="-SF" pgcli' alias pgcli='LESS="-SF" pgcli'
command -v bat &>/dev/null && alias cat="bat --plain" 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
}