neovim new config
This commit is contained in:
parent
763bbf5cc1
commit
315e988734
50 changed files with 739 additions and 52 deletions
48
home/afoucaultc/packages/neovim/lua/autocmd.lua
Normal file
48
home/afoucaultc/packages/neovim/lua/autocmd.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
-- (.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 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)
|
||||
|
||||
-- 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,
|
||||
})
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
pcall(vim.treesitter.start)
|
||||
end,
|
||||
})
|
||||
14
home/afoucaultc/packages/neovim/lua/lsp-config.lua
Normal file
14
home/afoucaultc/packages/neovim/lua/lsp-config.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- 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,
|
||||
})
|
||||
60
home/afoucaultc/packages/neovim/lua/remap.lua
Normal file
60
home/afoucaultc/packages/neovim/lua/remap.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
-- (.config/nvim/lua/neoconf/remap.lua)
|
||||
-- leader = space
|
||||
-- C = ctrl
|
||||
-- clear highlights when typing esc
|
||||
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
|
||||
-- diagnostic keymaps
|
||||
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
|
||||
-- exit terminal mode (or ctrl C)
|
||||
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
|
||||
-- disable arrow keys
|
||||
vim.keymap.set("n", "<left>", '<cmd>echo "Use h to move!!"<CR>')
|
||||
vim.keymap.set("n", "<right>", '<cmd>echo "Use l to move!!"<CR>')
|
||||
vim.keymap.set("n", "<up>", '<cmd>echo "Use k to move!!"<CR>')
|
||||
vim.keymap.set("n", "<down>", '<cmd>echo "Use j to move!!"<CR>')
|
||||
-- ctrl hjkl for moving between windows
|
||||
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
|
||||
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
|
||||
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
|
||||
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
|
||||
-- telescope
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
|
||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
|
||||
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 })
|
||||
|
||||
-- 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)
|
||||
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)
|
||||
end, { desc = "Toggle spell check" })
|
||||
|
||||
vim.api.nvim_create_user_command("OctaveRun", function()
|
||||
vim.cmd("write")
|
||||
vim.cmd('!octave -qf "%:p"')
|
||||
end, {})
|
||||
|
||||
-- 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)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lm", vimtex_set_main, { desc = "VimTeX: set main to current file" })
|
||||
46
home/afoucaultc/packages/neovim/lua/settings.lua
Normal file
46
home/afoucaultc/packages/neovim/lua/settings.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
-- .config/nvim/lua/neoconf/settings.lua
|
||||
vim.g.have_nerd_font = true
|
||||
-- options
|
||||
-- enable line number
|
||||
vim.o.number = true
|
||||
-- relative line number
|
||||
vim.o.relativenumber = true
|
||||
-- dont show the mode
|
||||
vim.o.showmode = true
|
||||
-- sync clipboard
|
||||
vim.schedule(function()
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
end)
|
||||
-- enable break indent
|
||||
vim.o.breakindent = true
|
||||
-- indent options
|
||||
vim.o.autoindent = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.expandtab = true
|
||||
-- save undo history
|
||||
vim.o.undofile = true
|
||||
-- case insensitive search
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
-- keep signcolumn
|
||||
vim.o.signcolumn = "yes"
|
||||
-- config new split opening
|
||||
vim.o.splitright = true
|
||||
vim.o.splitbelow = true
|
||||
-- whitespace char display
|
||||
vim.o.list = true
|
||||
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||
-- preview substitutions live with !
|
||||
vim.o.inccommand = "split"
|
||||
-- show line cursor
|
||||
vim.o.cursorline = true
|
||||
-- min lines above and below cursor
|
||||
vim.o.scrolloff = 10
|
||||
-- confirm save/confirm
|
||||
vim.o.confirm = true
|
||||
-- spell checking
|
||||
vim.opt.spell = true
|
||||
vim.opt.spelllang = "fr"
|
||||
-- wrap
|
||||
vim.o.wrap = true
|
||||
vim.o.linebreak = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue