neovim additions
This commit is contained in:
parent
315e988734
commit
409f13a1db
25 changed files with 242 additions and 86 deletions
|
|
@ -11,7 +11,7 @@
|
|||
pyright # python v2
|
||||
|
||||
# formatters
|
||||
nixfmt-rfc-style
|
||||
nixfmt
|
||||
stylua
|
||||
ruff
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@
|
|||
../plugins/lualine.nix
|
||||
../plugins/luasnip.nix
|
||||
../plugins/mini.nix
|
||||
../plugins/neogit.nix
|
||||
../plugins/noice.nix
|
||||
../plugins/oil.nix
|
||||
../plugins/snacks.nix
|
||||
../plugins/telescope.nix
|
||||
../plugins/treesitter.nix
|
||||
../plugins/vimtex.nix
|
||||
../plugins/web-devicons.nix
|
||||
../plugins/which-key.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,51 @@
|
|||
-- (.config/nvim/lua/neoconf/autocmd.lua)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end,
|
||||
})
|
||||
|
||||
local function run_curr_python_file()
|
||||
-- Get file name in the current buffer
|
||||
local file_name = vim.api.nvim_buf_get_name(0)
|
||||
-- Get file name in the current buffer
|
||||
local file_name = vim.api.nvim_buf_get_name(0)
|
||||
|
||||
-- Get terminal codes for running python file
|
||||
-- ("i" to enter insert before typing rest of the command)
|
||||
local py_cmd = vim.api.nvim_replace_termcodes('ipython "' .. file_name .. '"<cr>', true, false, true)
|
||||
-- Get terminal codes for running python file
|
||||
-- ("i" to enter insert before typing rest of the command)
|
||||
local py_cmd = vim.api.nvim_replace_termcodes('ipython "' .. file_name .. '"<cr>', true, false, true)
|
||||
|
||||
-- Determine terminal window split and launch terminal
|
||||
local percent_of_win = 0.4
|
||||
local curr_win_height = vim.api.nvim_win_get_height(0) -- Current window height
|
||||
local term_height = math.floor(curr_win_height * percent_of_win) -- Terminal height
|
||||
vim.cmd(":below " .. term_height .. "split | term") -- Launch terminal (horizontal split)
|
||||
-- Determine terminal window split and launch terminal
|
||||
local percent_of_win = 0.4
|
||||
local curr_win_height = vim.api.nvim_win_get_height(0) -- Current window height
|
||||
local term_height = math.floor(curr_win_height * percent_of_win) -- Terminal height
|
||||
vim.cmd(":below " .. term_height .. "split | term") -- Launch terminal (horizontal split)
|
||||
|
||||
-- Press keys to run python command on current file
|
||||
vim.api.nvim_feedkeys(py_cmd, "t", false)
|
||||
-- Press keys to run python command on current file
|
||||
vim.api.nvim_feedkeys(py_cmd, "t", false)
|
||||
end
|
||||
|
||||
vim.keymap.set({ "n" }, "<A-r>", "", {
|
||||
desc = "Run .py file via Neovim built-in terminal",
|
||||
callback = run_curr_python_file,
|
||||
desc = "Run .py file via Neovim built-in terminal",
|
||||
callback = run_curr_python_file,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "markdown", "rmd" },
|
||||
callback = function()
|
||||
-- Force syntaxe markdown
|
||||
vim.bo.syntax = "markdown"
|
||||
-- Conceal normal pour markdown
|
||||
vim.wo.conceallevel = 2
|
||||
-- Désactive vimtex pour ces fichiers
|
||||
vim.b.vimtex_syntax_enabled = 0
|
||||
end,
|
||||
pattern = { "markdown", "rmd" },
|
||||
callback = function()
|
||||
-- Force syntaxe markdown
|
||||
vim.bo.syntax = "markdown"
|
||||
-- Conceal normal pour markdown
|
||||
vim.wo.conceallevel = 2
|
||||
-- Désactive vimtex pour ces fichiers
|
||||
vim.b.vimtex_syntax_enabled = 0
|
||||
-- spellcheck
|
||||
vim.wo.spell = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
pcall(vim.treesitter.start)
|
||||
local ok = pcall(vim.treesitter.start)
|
||||
if ok then
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- active spell sur .tex
|
||||
vim.api.nvim_create_autocmd("FileType", { pattern = "tex", callback = function() vim.wo.spell = true end })
|
||||
|
||||
vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank() end })
|
||||
|
|
|
|||
|
|
@ -1,14 +1,48 @@
|
|||
-- diagnostic
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
prefix = "●", -- Icône avant le message
|
||||
source = "if_many", -- Affiche la source LSP si plusieurs
|
||||
format = function(diag)
|
||||
return string.format("%s: %s", diag.source, diag.message)
|
||||
end,
|
||||
},
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false, -- Évite flicker en insert
|
||||
severity_sort = true,
|
||||
virtual_text = {
|
||||
prefix = "●",
|
||||
source = "if_many",
|
||||
format = function(diag)
|
||||
return string.format("%s: %s", diag.source, diag.message)
|
||||
end,
|
||||
},
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "[d", function()
|
||||
vim.diagnostic.jump({ count = -1, float = true })
|
||||
end, { desc = "Previous diagnostic" })
|
||||
vim.keymap.set("n", "]d", function()
|
||||
vim.diagnostic.jump({ count = 1, float = true })
|
||||
end, { desc = "Next diagnostic" })
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
desc = "Configure LSP keymaps on attach",
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc)
|
||||
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
map("gd", vim.lsp.buf.definition, "Goto Definition")
|
||||
map("gD", vim.lsp.buf.declaration, "Goto Declaration")
|
||||
map("gr", vim.lsp.buf.references, "Goto References")
|
||||
map("gI", vim.lsp.buf.implementation, "Goto Implementation")
|
||||
map("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
map("<leader>rn", vim.lsp.buf.rename, "Rename")
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "Code Action")
|
||||
map("<leader>ds", vim.lsp.buf.document_symbol, "Document Symbols")
|
||||
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
if client and client:supports_method("textDocument/inlayHint") then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = event.buf })
|
||||
map("<leader>th", function()
|
||||
local enabled = vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })
|
||||
vim.lsp.inlay_hint.enable(not enabled, { bufnr = event.buf })
|
||||
end, "Toggle Inlay Hints")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -25,36 +25,35 @@ vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers"
|
|||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
|
||||
-- oil
|
||||
vim.keymap.set("n", "<leader>n", "<cmd>Oil<CR>", { desc = "Launch oil buffer" })
|
||||
-- python
|
||||
vim.keymap.set("n", "<F5>", ":w<CR>:!python3 %<CR>", { noremap = true, silent = false })
|
||||
|
||||
vim.keymap.set("n", "-", "<cmd>Oil<CR>", { desc = "Open parent directory" })
|
||||
-- spell checker from fr to en
|
||||
vim.keymap.set("n", "<leader>sf", function()
|
||||
if vim.o.spelllang == "fr" then
|
||||
vim.o.spelllang = "en"
|
||||
else
|
||||
vim.o.spelllang = "fr"
|
||||
end
|
||||
vim.o.spell = true
|
||||
print("Spelllang: " .. vim.o.spelllang)
|
||||
if vim.o.spelllang == "fr" then
|
||||
vim.o.spelllang = "en"
|
||||
else
|
||||
vim.o.spelllang = "fr"
|
||||
end
|
||||
vim.o.spell = true
|
||||
print("Spelllang: " .. vim.o.spelllang)
|
||||
end, { desc = "Toggle spelllang FR/EN" })
|
||||
-- toggle correction
|
||||
vim.keymap.set("n", "<leader>sg", function()
|
||||
vim.wo.spell = not vim.wo.spell
|
||||
vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF"), vim.log.levels.INFO)
|
||||
vim.wo.spell = not vim.wo.spell
|
||||
vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF"), vim.log.levels.INFO)
|
||||
end, { desc = "Toggle spell check" })
|
||||
|
||||
vim.api.nvim_create_user_command("OctaveRun", function()
|
||||
vim.cmd("write")
|
||||
vim.cmd('!octave -qf "%:p"')
|
||||
vim.cmd("write")
|
||||
vim.cmd('!octave -qf "%:p"')
|
||||
end, {})
|
||||
vim.keymap.set("n", "<leader>ro", "<cmd>OctaveRun<CR>", { desc = "Run current Octave/Matlab file" })
|
||||
|
||||
-- set vimtex main to current file
|
||||
local function vimtex_set_main()
|
||||
vim.b.vimtex_main = vim.fn.expand("%:p")
|
||||
vim.b.vimtex = nil
|
||||
vim.fn["vimtex#init"]()
|
||||
print("VimTeX main → " .. vim.b.vimtex_main)
|
||||
vim.b.vimtex_main = vim.fn.expand("%:p")
|
||||
vim.b.vimtex = nil
|
||||
vim.fn["vimtex#init"]()
|
||||
print("VimTeX main → " .. vim.b.vimtex_main)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lm", vimtex_set_main, { desc = "VimTeX: set main to current file" })
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ vim.o.relativenumber = true
|
|||
vim.o.showmode = true
|
||||
-- sync clipboard
|
||||
vim.schedule(function()
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
end)
|
||||
-- enable break indent
|
||||
vim.o.breakindent = true
|
||||
-- indent options
|
||||
vim.o.autoindent = true
|
||||
vim.o.smartindent = true
|
||||
-- vim.o.smartindent = true
|
||||
vim.o.expandtab = true
|
||||
-- save undo history
|
||||
vim.o.undofile = true
|
||||
|
|
@ -39,8 +39,15 @@ vim.o.scrolloff = 10
|
|||
-- confirm save/confirm
|
||||
vim.o.confirm = true
|
||||
-- spell checking
|
||||
vim.opt.spell = true
|
||||
-- vim.opt.spell = true
|
||||
vim.opt.spelllang = "fr"
|
||||
-- wrap
|
||||
vim.o.wrap = true
|
||||
vim.o.linebreak = true
|
||||
-- indent
|
||||
vim.o.shiftwidth = 4
|
||||
vim.o.tabstop = 4
|
||||
vim.o.softtabstop = 4
|
||||
-- timers
|
||||
vim.o.updatetime = 250
|
||||
vim.o.timeoutlen = 300
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ inputs, ... }:
|
||||
{ inputs, pkgs, ... }:
|
||||
let
|
||||
nixvim = import (
|
||||
builtins.fetchGit {
|
||||
|
|
@ -23,5 +23,6 @@ in
|
|||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
nixpkgs.source = pkgs.path;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@
|
|||
nix = [ "nixfmt" ];
|
||||
lua = [ "stylua" ];
|
||||
python = [ "ruff_format" ];
|
||||
format_on_save = {
|
||||
lsp_fallback = true;
|
||||
timeout_ms = 500;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,61 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
gitsigns = {
|
||||
enable = true;
|
||||
programs.nixvim.plugins.gitsigns.enable = true;
|
||||
|
||||
programs.nixvim.keymaps = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "]c";
|
||||
action.__raw = ''
|
||||
function()
|
||||
if vim.wo.diff then return "]c" end
|
||||
vim.schedule(function() require("gitsigns").nav_hunk("next") end)
|
||||
return "<Ignore>"
|
||||
end
|
||||
'';
|
||||
options = {
|
||||
desc = "Next git hunk";
|
||||
expr = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "[c";
|
||||
action.__raw = ''
|
||||
function()
|
||||
if vim.wo.diff then return "[c" end
|
||||
vim.schedule(function() require("gitsigns").nav_hunk("prev") end)
|
||||
return "<Ignore>"
|
||||
end
|
||||
'';
|
||||
options = {
|
||||
desc = "Previous git hunk";
|
||||
expr = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>hs";
|
||||
action.__raw = ''function() require("gitsigns").stage_hunk() end'';
|
||||
options.desc = "Stage hunk";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>hr";
|
||||
action.__raw = ''function() require("gitsigns").reset_hunk() end'';
|
||||
options.desc = "Reset hunk";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>hp";
|
||||
action.__raw = ''function() require("gitsigns").preview_hunk() end'';
|
||||
options.desc = "Preview hunk";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>hb";
|
||||
action.__raw = ''function() require("gitsigns").blame_line({ full = true }) end'';
|
||||
options.desc = "Blame line";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
enable = true;
|
||||
servers = {
|
||||
nil_ls.enable = true;
|
||||
lua-ls = {
|
||||
lua_ls = {
|
||||
enable = true;
|
||||
settings.Lua.diagnostics.globals = [ "vim" ];
|
||||
};
|
||||
|
|
|
|||
16
home/afoucaultc/packages/neovim/plugins/neogit.nix
Normal file
16
home/afoucaultc/packages/neovim/plugins/neogit.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim.plugins = {
|
||||
neogit.enable = true;
|
||||
diffview.enable = true; # compagnon habituel de neogit pour les diffs
|
||||
};
|
||||
|
||||
programs.nixvim.keymaps = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>gg";
|
||||
action = "<cmd>Neogit<cr>";
|
||||
options.desc = "Open Neogit";
|
||||
}
|
||||
];
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/noice.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/noice.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim.plugins.noice = {
|
||||
enable = true;
|
||||
settings.lsp = {
|
||||
"vim.lsp.util.convert_input_to_markdown_lines" = true;
|
||||
"vim.lsp.util.stylize_markdown" = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
11
home/afoucaultc/packages/neovim/plugins/snacks.nix
Normal file
11
home/afoucaultc/packages/neovim/plugins/snacks.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim.plugins.snacks = {
|
||||
enable = true;
|
||||
settings = {
|
||||
bigfile.enabled = true; # gère proprement les très gros fichiers
|
||||
quickfile.enabled = true; # affichage plus rapide au démarrage
|
||||
indent.enabled = true; # guides d'indentation visuels
|
||||
};
|
||||
};
|
||||
}
|
||||
8
home/afoucaultc/packages/neovim/plugins/web-devicons.nix
Normal file
8
home/afoucaultc/packages/neovim/plugins/web-devicons.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
web-devicons.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,10 +1,17 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
which-key = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
programs.nixvim.plugins.which-key.enable = true;
|
||||
|
||||
programs.nixvim.extraConfigLua = ''
|
||||
require("which-key").add({
|
||||
{ "<leader>f", group = "Find" },
|
||||
{ "<leader>g", group = "Git" },
|
||||
{ "<leader>h", group = "Git Hunk" },
|
||||
{ "<leader>s", group = "Spell" },
|
||||
{ "<leader>c", group = "Code" },
|
||||
{ "<leader>r", group = "Run" },
|
||||
{ "<leader>l", group = "LaTeX" },
|
||||
{ "<leader>t", group = "Toggle" },
|
||||
})
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue