Compare commits
4 Commits
71f3906774
...
28714d5f8a
| Author | SHA1 | Date | |
|---|---|---|---|
| 28714d5f8a | |||
| 692c87e1ba | |||
| 653f44935a | |||
| 714fb7ef37 |
@@ -17,3 +17,8 @@ vim.keymap.set("n", "N", "Nzzzv")
|
||||
-- Move block on visual mode
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- Diagnostic (erreurs LSP)
|
||||
vim.keymap.set('n', 'gl', vim.diagnostic.open_float, { desc = 'Show diagnostic' })
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Previous diagnostic' })
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Next diagnostic' })
|
||||
|
||||
@@ -1,77 +1,22 @@
|
||||
-- return {
|
||||
-- 'hrsh7th/nvim-cmp',
|
||||
-- dependencies = {
|
||||
-- 'neovim/nvim-lspconfig',
|
||||
-- 'hrsh7th/cmp-nvim-lsp',
|
||||
-- 'hrsh7th/cmp-buffer',
|
||||
-- 'hrsh7th/cmp-path',
|
||||
-- 'hrsh7th/cmp-cmdline',
|
||||
-- 'hrsh7th/cmp-vsnip',
|
||||
-- 'hrsh7th/vim-vsnip',
|
||||
-- },
|
||||
-- config = function ()
|
||||
-- local cmp = require'cmp'
|
||||
-- cmp.setup({
|
||||
-- snippet = {
|
||||
-- expand = function(args)
|
||||
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
-- end,
|
||||
-- },
|
||||
-- window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
-- },
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'nvim_lsp' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
-- { name = 'path' },
|
||||
-- {
|
||||
-- name = 'buffer',
|
||||
-- option = {
|
||||
-- keyword_length = 3,
|
||||
-- get_bufnrs = function()
|
||||
-- return vim.api.nvim_list_bufs()
|
||||
-- end
|
||||
-- }
|
||||
-- },
|
||||
-- }, {
|
||||
-- { name = 'buffer' },
|
||||
-- })
|
||||
-- })
|
||||
--
|
||||
-- -- Set configuration for specific filetype.
|
||||
-- cmp.setup.filetype('gitcommit', {
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
-- }, {
|
||||
-- { name = 'buffer' },
|
||||
-- })
|
||||
-- })
|
||||
--
|
||||
-- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
-- cmp.setup.cmdline({ '/', '?' }, {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = {
|
||||
-- { name = 'buffer' }
|
||||
-- }
|
||||
-- })
|
||||
--
|
||||
-- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
-- cmp.setup.cmdline(':', {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'path' }
|
||||
-- }, {
|
||||
-- { name = 'cmdline' }
|
||||
-- })
|
||||
-- })
|
||||
-- end
|
||||
-- }
|
||||
|
||||
return {
|
||||
"saghen/blink.cmp",
|
||||
-- optional: provides snippets for the snippet source
|
||||
dependencies = { "rafamadriz/friendly-snippets" },
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
build = "make install_jsregexp",
|
||||
config = function()
|
||||
require("luasnip").setup({
|
||||
store_selection_keys = "<Tab>",
|
||||
})
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_lua").lazy_load({
|
||||
paths = { "~/.config/nvim/snippets" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
-- use a release tag to download pre-built binaries
|
||||
version = "1.*",
|
||||
@@ -106,15 +51,28 @@ return {
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = {
|
||||
documentation = {
|
||||
auto_show = false,
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 200,
|
||||
},
|
||||
ghost_text = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
|
||||
-- Default list of enabled providers defined so that you can extend it
|
||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||
sources = {
|
||||
default = { "lsp", "path", "snippets", "buffer" },
|
||||
providers = {
|
||||
buffer = {
|
||||
min_keyword_length = 3,
|
||||
score_offset = -10,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
snippets = {
|
||||
preset = "luasnip",
|
||||
},
|
||||
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
|
||||
153
nvim/.config/nvim/lua/plugins/harpoon.lua
Normal file
153
nvim/.config/nvim/lua/plugins/harpoon.lua
Normal file
@@ -0,0 +1,153 @@
|
||||
-- plugins/h-- plugins/harpoon.lua
|
||||
return {
|
||||
"ThePrimeagen/harpoon",
|
||||
branch = "harpoon2",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local harpoon = require("harpoon")
|
||||
|
||||
-- Setup Harpoon pour sessions temporaires (pas de persistence)
|
||||
harpoon:setup({
|
||||
settings = {
|
||||
save_on_toggle = false, -- Pas de sauvegarde automatique
|
||||
sync_on_ui_close = false, -- Pas de sync à la fermeture
|
||||
save_on_change = true, -- Sauvegarde les changements dans la session
|
||||
excluded_filetypes = { "harpoon", "alpha", "dashboard", "gitcommit", "fugitive" },
|
||||
},
|
||||
})
|
||||
|
||||
-- === Fonction helper pour arrêter VimTeX ===
|
||||
local function stop_all_vimtex()
|
||||
-- Récupérer tous les buffers LaTeX ouverts
|
||||
local latex_buffers = {}
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
local filetype = vim.api.nvim_buf_get_option(buf, "filetype")
|
||||
if filetype == "tex" or filetype == "latex" then
|
||||
table.insert(latex_buffers, buf)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Arrêter VimTeX pour chaque buffer LaTeX
|
||||
for _, buf in ipairs(latex_buffers) do
|
||||
-- Switcher temporairement vers ce buffer pour exécuter VimtexStop
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_set_current_buf(buf)
|
||||
|
||||
if vim.fn.exists(":VimtexStop") == 2 then
|
||||
pcall(vim.cmd, "VimtexStop") -- pcall pour éviter les erreurs
|
||||
end
|
||||
|
||||
-- Revenir au buffer original
|
||||
if vim.api.nvim_buf_is_valid(current_buf) then
|
||||
vim.api.nvim_set_current_buf(current_buf)
|
||||
end
|
||||
end
|
||||
|
||||
-- Alternative plus robuste: tuer directement les processus latexmk
|
||||
local handle = io.popen("pgrep -f latexmk")
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
if result and result ~= "" then
|
||||
os.execute("pkill -f latexmk")
|
||||
print("Killed background latexmk processes")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Keymaps AZERTY-friendly groupés sous <leader>h
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
-- === Gestion de session ===
|
||||
keymap("n", "<leader>ha", function()
|
||||
harpoon:list():append()
|
||||
print("Added: " .. vim.fn.expand("%:t"))
|
||||
end, { desc = "Harpoon: Add file to session" })
|
||||
|
||||
keymap("n", "<leader>hm", function()
|
||||
harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||
end, { desc = "Harpoon: Toggle menu" })
|
||||
|
||||
keymap("n", "<leader>hc", function()
|
||||
-- Confirmation simple
|
||||
local choice = vim.fn.confirm("Clear session and stop VimTeX?", "&Yes\n&No", 2)
|
||||
|
||||
-- Si No, on fait rien
|
||||
if choice ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Arrêter toutes les compilations VimTeX
|
||||
stop_all_vimtex()
|
||||
|
||||
-- Clear Harpoon
|
||||
harpoon:list():clear()
|
||||
|
||||
-- Fermer tous les buffers
|
||||
vim.cmd("silent! %bdelete")
|
||||
|
||||
print("Session cleared, VimTeX stopped, buffers closed!")
|
||||
end, { desc = "Harpoon: Clear session & stop VimTeX" })
|
||||
|
||||
-- === Navigation directe (rangée de base AZERTY) ===
|
||||
local nav_keys = {
|
||||
{ key = "q", pos = 1 },
|
||||
{ key = "s", pos = 2 },
|
||||
{ key = "d", pos = 3 },
|
||||
{ key = "f", pos = 4 },
|
||||
{ key = "g", pos = 5 },
|
||||
{ key = "h", pos = 6 },
|
||||
}
|
||||
|
||||
for _, mapping in ipairs(nav_keys) do
|
||||
keymap("n", "<leader>h" .. mapping.key, function()
|
||||
harpoon:list():select(mapping.pos)
|
||||
end, { desc = "Harpoon: Go to file " .. mapping.pos })
|
||||
end
|
||||
|
||||
-- === Navigation cyclique ===
|
||||
keymap("n", "<leader>hn", function()
|
||||
harpoon:list():next()
|
||||
end, { desc = "Harpoon: Next file" })
|
||||
|
||||
keymap("n", "<leader>hp", function()
|
||||
harpoon:list():prev()
|
||||
end, { desc = "Harpoon: Previous file" })
|
||||
|
||||
-- === Commandes utiles ===
|
||||
vim.api.nvim_create_user_command("HarpoonClear", function()
|
||||
harpoon:list():clear()
|
||||
print("Harpoon session cleared!")
|
||||
end, { desc = "Clear current Harpoon session" })
|
||||
|
||||
vim.api.nvim_create_user_command("HarpoonList", function()
|
||||
local list = harpoon:list()
|
||||
if #list.items == 0 then
|
||||
print("No files in Harpoon session")
|
||||
return
|
||||
end
|
||||
|
||||
print("Current Harpoon session:")
|
||||
for i, item in ipairs(list.items) do
|
||||
print(string.format(" %d. %s", i, item.value))
|
||||
end
|
||||
end, { desc = "List files in current Harpoon session" })
|
||||
end,
|
||||
|
||||
-- Chargement paresseux: seulement quand on utilise les keymaps
|
||||
keys = {
|
||||
{ "<leader>ha", desc = "Harpoon: Add file" },
|
||||
{ "<leader>hm", desc = "Harpoon: Menu" },
|
||||
{ "<leader>hc", desc = "Harpoon: Clear & stop VimTeX" },
|
||||
{ "<leader>hq", desc = "Harpoon: File 1" },
|
||||
{ "<leader>hs", desc = "Harpoon: File 2" },
|
||||
{ "<leader>hd", desc = "Harpoon: File 3" },
|
||||
{ "<leader>hf", desc = "Harpoon: File 4" },
|
||||
{ "<leader>hg", desc = "Harpoon: File 5" },
|
||||
{ "<leader>hh", desc = "Harpoon: File 6" },
|
||||
{ "<leader>hn", desc = "Harpoon: Next" },
|
||||
{ "<leader>hp", desc = "Harpoon: Previous" },
|
||||
},
|
||||
}
|
||||
@@ -1,27 +1,59 @@
|
||||
return {
|
||||
'nvim-telescope/telescope.nvim', branch = '0.1.x',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
opts = {
|
||||
defaults = {
|
||||
file_ignore_patterns = { "**/*.pdf" },
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = { prompt_position = "top" },
|
||||
sorting_strategy = "ascending",
|
||||
winblend = 0,
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{"<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files"},
|
||||
{"<leader>fe", "<cmd>Telescope git_files<cr>", desc = "Find file respecting .gitignore"},
|
||||
{"<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Grep file in file"},
|
||||
{"<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Search through buffers"},
|
||||
{"<leader>ft", "<cmd>Telescope tags<cr>", desc = "Search through tags"},
|
||||
{"<leader>fm", "<cmd>Telescope marks<cr>", desc = "Search through marks"},
|
||||
{"<leader>fs", "<cmd>Telescope search_history<cr>", desc = "Search through search"},
|
||||
},
|
||||
config = function()
|
||||
require('telescope').setup(
|
||||
|
||||
)
|
||||
end
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
opts = {
|
||||
defaults = {
|
||||
file_ignore_patterns = { "**/*.pdf" },
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = {
|
||||
horizontal = {
|
||||
prompt_position = "top",
|
||||
preview_width = 0.55,
|
||||
},
|
||||
width = 0.87,
|
||||
height = 0.80,
|
||||
preview_cutoff = 120,
|
||||
},
|
||||
sorting_strategy = "ascending",
|
||||
borderchars = { "█", "█", "█", "█", "█", "█", "█", "█" },
|
||||
prompt_prefix = " 🔍 ",
|
||||
selection_caret = " ➜ ",
|
||||
entry_prefix = " ",
|
||||
winblend = 0,
|
||||
results_title = "",
|
||||
prompt_title = "",
|
||||
preview_title = "",
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-d>"] = require("telescope.actions").delete_buffer,
|
||||
},
|
||||
n = {
|
||||
["<C-d>"] = require("telescope.actions").delete_buffer,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("telescope").setup(opts)
|
||||
vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptNormal", { bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopeResultsNormal", { bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePreviewNormal", { bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptBorder", { fg = "#3c3836", bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopeResultsBorder", { fg = "#3c3836", bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePreviewBorder", { fg = "#3c3836", bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptTitle", { fg = "#3c3836", bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopeResultsTitle", { fg = "#3c3836", bg = "#3c3836" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePreviewTitle", { fg = "#3c3836", bg = "#3c3836" })
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<leader>fe", "<cmd>Telescope git_files<cr>", desc = "Find file respecting .gitignore" },
|
||||
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Grep file in file" },
|
||||
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Search through buffers" },
|
||||
{ "<leader>ft", "<cmd>Telescope tags<cr>", desc = "Search through tags" },
|
||||
{ "<leader>fm", "<cmd>Telescope marks<cr>", desc = "Search through marks" },
|
||||
{ "<leader>fs", "<cmd>Telescope search_history<cr>", desc = "Search through search" },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ opt.number = true -- show line number
|
||||
opt.relativenumber = true -- show relative line number
|
||||
opt.cursorline = true -- highlight current line
|
||||
|
||||
opt.scrolloff = 8 -- Keep 8 lines visible above/below cursor
|
||||
opt.ignorecase = true -- Ignore case on search
|
||||
opt.smartcase = true -- ignore lowercse for the whoel pattern
|
||||
|
||||
|
||||
15
nvim/.config/nvim/snippets/package.json
Normal file
15
nvim/.config/nvim/snippets/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "custom-latex-snippets",
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"language": "tex",
|
||||
"path": "./snippets/latex.json"
|
||||
},
|
||||
{
|
||||
"language": "latex",
|
||||
"path": "./snippets/latex.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
57
nvim/.config/nvim/snippets/tex.lua
Normal file
57
nvim/.config/nvim/snippets/tex.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
local ls = require("luasnip")
|
||||
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 d = ls.dynamic_node
|
||||
|
||||
return {
|
||||
-- Minipage avec texte sélectionné
|
||||
s({ trig = "minipage", dscr = "Minipage environment" }, {
|
||||
t("\\begin{minipage}{"),
|
||||
i(1, "0.5"),
|
||||
t("\\textwidth}"),
|
||||
t({ "", "\t" }),
|
||||
d(2, function(_, snip)
|
||||
return sn(nil, i(1, snip.env.LS_SELECT_RAW or ""))
|
||||
end),
|
||||
t({ "", "\\end{minipage}" }),
|
||||
}),
|
||||
|
||||
-- Multicols avec texte sélectionné
|
||||
s({ trig = "multicols", dscr = "Multicols environment" }, {
|
||||
t("\\begin{multicols}{"),
|
||||
i(1, "2"),
|
||||
t("}"),
|
||||
t({ "", "\t" }),
|
||||
d(2, function(_, snip)
|
||||
return sn(nil, i(1, snip.env.LS_SELECT_RAW or ""))
|
||||
end),
|
||||
t({ "", "\\end{multicols}" }),
|
||||
}),
|
||||
|
||||
-- Deux minipages côte à côte
|
||||
s({ trig = "minipage2", dscr = "Two minipages side by side" }, {
|
||||
t("\\begin{minipage}{"),
|
||||
i(1, "0.48"),
|
||||
t("\\textwidth}"),
|
||||
t({ "", "\t" }),
|
||||
i(2),
|
||||
t({ "", "\\end{minipage}" }),
|
||||
t({ "", "\\hfill" }),
|
||||
t({ "", "\\begin{minipage}{" }),
|
||||
f(function(args)
|
||||
local width = tonumber(args[1][1])
|
||||
if width then
|
||||
return tostring(1 - width)
|
||||
else
|
||||
return "0.48"
|
||||
end
|
||||
end, { 1 }),
|
||||
t("\\textwidth}"),
|
||||
t({ "", "\t" }),
|
||||
i(0),
|
||||
t({ "", "\\end{minipage}" }),
|
||||
}),
|
||||
}
|
||||
Reference in New Issue
Block a user