neovim additions
This commit is contained in:
parent
315e988734
commit
409f13a1db
25 changed files with 242 additions and 86 deletions
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue