Compare commits

..

No commits in common. "master" and "debug" have entirely different histories.

13 changed files with 21 additions and 371 deletions

View File

@ -18,8 +18,3 @@ snippet it "item"
\item $0
endsnippet
snippet listing "Listing"
\begin{lstlisting}
$0
\end{lstlisting}
endsnippet

View File

@ -2,48 +2,4 @@ require("config.options")
require("config.keymaps")
require("config.lazy")
require("custom.functions")
local viewgroup = vim.api.nvim_create_augroup("RememberFolds", { clear = true })
local allowed_rem_filetypes = {
lua = true,
python = true,
r = true,
bash = true,
c = true,
sql = true,
["c++"] = true, -- in case filetype is "c++"
cpp = true, -- sometimes C++ is "cpp"
java = true,
rust = true,
go = true,
wiki = true,
vimwiki = true,
}
vim.api.nvim_create_autocmd("BufWinLeave", {
group = viewgroup,
pattern = "*",
callback = function()
-- Exclude terminal and Telescope buffers from mkview
local ft = vim.bo.filetype:lower()
if not allowed_rem_filetypes[ft] then
return
end
vim.cmd("mkview")
end,
})
vim.api.nvim_create_autocmd("BufWinEnter", {
group = viewgroup,
pattern = "*",
callback = function()
-- Exclude terminal and Telescope buffers from loadview
local ft = vim.bo.filetype:lower()
if not allowed_rem_filetypes[ft] then
return
end
vim.cmd("silent! loadview")
end,
})
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
-- require("custom.chatgpt")

View File

@ -6,8 +6,8 @@ vim.keymap.set('n','<space><tab>',':b#<CR>', {noremap=true, silent=true})
vim.keymap.set('n', '<leader>cd', ':cd %:p:h<CR>', {noremap=true, silent=true})
vim.api.nvim_set_keymap('n', '<leader>ff', '<cmd>Telescope find_files<cr>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>rg', '<cmd>Telescope grep_string search="" only_sort_text=true<cr>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>bb', '<cmd>Telescope buffers<cr>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>fb', '<cmd>Telescope buffers<cr>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', {noremap = true, silent = true})
vim.keymap.set('n', '-', '/', { noremap = true, silent = true })
@ -20,16 +20,3 @@ vim.keymap.set('n', 'z7', '<cmd>Telescope spell_suggest<cr>', { noremap = true,
vim.keymap.set('n', '<F5>', ':set ignorecase!<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<F6>',':set spell! spelllang=hu<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<F7>',':set spell! spelllang=en<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap(
"n",
"<space>lf",
"<cmd>lua require('custom.fold_telescope').jump_to_fold_starts()<CR>",
{ noremap = true, silent = true }
)
vim.api.nvim_set_keymap(
"n",
"<space>ll",
"<cmd>lua require('custom.line_telescope').jump_to_line()<CR>",
{ noremap = true, silent = true }
)

View File

@ -1,4 +1,3 @@
vim.opt.termguicolors = true -- True color support
vim.opt.hlsearch = false -- Disable highlighting search matches
vim.opt.hidden = true -- Allow background buffers
vim.opt.cindent = true
@ -10,5 +9,5 @@ vim.opt.mouse="a"
vim.opt.clipboard="unnamedplus"
vim.g.mapleader = " "
vim.g.maplocalleader = ","
-- vim.opt.spell = true
vim.opt.spell = true
vim.opt.ignorecase = true

View File

@ -6,8 +6,6 @@ return {
vim.api.nvim_set_keymap('n', '<M-s>', '<Plug>(easymotion-s2)', {})
vim.api.nvim_set_keymap('n', '<M-l>', '<Plug>(easymotion-lineanywhere)', {})
vim.api.nvim_set_keymap('n', '<M-j>', '<Plug>(easymotion-jumptoanywhere)', {})
vim.g.EasyMotion_keys = 'asdghklqwertzuiopzxcvbnmfjé'
end
},
}

View File

@ -1,24 +1,8 @@
return {
{'vimwiki/vimwiki'},
{'tpope/vim-fugitive'},
{'gorkunov/smartpairs.vim'},
{'tpope/vim-surround'},
{'echasnovski/mini.ai',
config = function()
require('mini.ai').setup()
end},
{'jiangmiao/auto-pairs'},
{'github/copilot.vim',
config = function()
vim.keymap.set('i', '<C-J>', 'copilot#Accept("\\<CR>")', { expr = true, replace_keycodes = false })
vim.keymap.set('i', '<C-L>', '<Plug>(copilot-accept-word)')
vim.keymap.set('i', '<PageDown>', '<Plug>(copilot-previous)')
vim.keymap.set('i', '<PageUp>', '<Plug>(copilot-next)')
vim.keymap.set('i', '<Home>', '<Plug>(copilot-suggest)')
vim.keymap.set('i', '<M-Left>', '<esc>dawi<Right>')
vim.g.copilot_no_tab_map=true
end
},
{'mattn/emmet-vim',
ft = { 'html', 'css', 'javascript', 'typescript', 'vue' },
}

View File

@ -7,7 +7,6 @@ return {
iron.setup {
config = {
-- Whether a repl should be discarded or not
highlight_last = false,
scratch_repl = false,
-- Your repl definitions come here
repl_definition = {
@ -23,7 +22,7 @@ return {
},
-- How the repl window will be displayed
-- See below for more information
repl_open_cmd = 'belowright 20split' --require('iron.view').split.below(80),
repl_open_cmd = require('iron.view').split.below(80),
},
-- Iron doesn't set keymaps by default anymore.
-- You can set them here or manually add keymaps to the functions in iron.core

View File

@ -1,19 +0,0 @@
return {
"lervag/vimtex",
lazy = false, -- we don't want to lazy load VimTeX
-- tag = "v2.15", -- uncomment to pin to a specific release
init = function()
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_compiler_latexmk = {
options = {
"-pdf",
"-shell-escape",
"-verbose",
"-file-line-error",
"-synctex=1",
"-interaction=nonstopmode",
},
}
end
}

View File

@ -2,7 +2,6 @@ return {
-- Mason for managing external tools (LSP servers, linters, etc.)
{
"williamboman/mason.nvim",
version = "=1.0.1",
config = function()
require("mason").setup()
end
@ -10,11 +9,9 @@ return {
-- Mason LSP config to bridge Mason and nvim-lspconfig
{
"williamboman/mason-lspconfig.nvim",
version = "=1.0.1",
config = function()
require("mason-lspconfig").setup {
ensure_installed = {"pyright"},
automatic_installation = false, -- Set to true to automatically install servers
ensure_installed = {"pyright"}
}
end
},

View File

@ -1,33 +1,19 @@
return {
{
-- Main Telescope plugin
"nvim-telescope/telescope.nvim",
version = "0.1.8", -- or branch = '0.1.x'
dependencies = {
"nvim-lua/plenary.nvim",
{
-- FZF native plugin for better fuzzy matching
"nvim-telescope/telescope-fzf-native.nvim",
build = "make", -- Lazy will run `make` when installing/updating
-- If you want to ensure 'make' is available, you can do:
-- cond = function()
-- return vim.fn.executable("make") == 1
-- end,
},
},
cmd = "Telescope", -- load only when calling Telescope
'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
require("telescope").setup({
require('telescope').setup{
defaults = {
mappings = {
i = {
["<esc>"] = require("telescope.actions").close,
},
},
},
})
-- After setup, load the FZF extension (it must be built successfully first)
require("telescope").load_extension("fzf")
["<esc>"] = require('telescope.actions').close
}
}
}
}
end,
},
}
cmd = 'Telescope'
}

View File

@ -1,69 +0,0 @@
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
-- Utility: Given a line number, returns the fold's starting line.
local function get_fold_start(l)
local closed = vim.fn.foldclosed(l)
if closed ~= -1 then
return closed
else
local level = vim.fn.foldlevel(l)
if level == 0 then
return l
end
local start = l
while start > 1 and vim.fn.foldlevel(start - 1) >= level do
start = start - 1
end
return start
end
end
local function jump_to_fold_starts()
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
local entries = {}
local prev_level = 0
-- Detect fold-start lines by checking if foldlevel increases.
for i, line in ipairs(lines) do
local current_level = vim.fn.foldlevel(i)
if current_level > prev_level then
table.insert(entries, {
value = line,
display = string.format("%d: %s", i, line),
ordinal = line,
file_line = i, -- Save the actual file line number.
})
end
prev_level = current_level
end
pickers.new({}, {
prompt_title = "Fold Starts",
finder = finders.new_table {
results = entries,
entry_maker = function(entry)
return entry -- Already in the expected shape.
end,
},
sorter = conf.generic_sorter({}),
attach_mappings = function(prompt_bufnr, _)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
if selection then
local target_line = get_fold_start(selection.file_line)
vim.cmd(string.format("normal! %dG", target_line))
vim.cmd("normal! zv")
end
end)
return true
end,
}):find()
end
-- Expose the function so you can require it.
return { jump_to_fold_starts = jump_to_fold_starts }

View File

@ -1,67 +1,9 @@
-- Alternatively, using a Lua function
local function lines_with_preview()
local current_file = vim.fn.fnameescape(vim.fn.expand('%'))
local rg_command = string.format("rg --with-filename --column --line-number --no-heading --color=always --smart-case . %s", current_file)
local fzf_command = string.format("call fzf#vim#grep('%s', 1, fzf#vim#with_preview({'options': '--delimiter : --nth 4.. --no-sort'}, 'up:50%%', '?'), 1)", rg_command)
vim.cmd(fzf_command)
end
function DevtoolsPath()
local devPath = vim.fn.trim(vim.fn.system('ls ' .. vim.fn.expand("%:p:h") .. ' | grep DESCRIPTION'))
if devPath == "" then
devPath = vim.fn.trim(vim.fn.system('realpath ' .. vim.fn.expand("%:p:h") .. '/../'))
return devPath
else
devPath = vim.fn.expand('%:p:h')
return devPath
end
end
vim.api.nvim_create_user_command('LinesWithPreview', lines_with_preview, {})
vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, {
pattern = "DESCRIPTION",
command = "set filetype=r"
})
local function IronQuiteSend(opts)
-- Get the current filetype to send to the appropriate REPL
local ft = vim.bo.filetype
-- Concatenate all arguments passed to the command
local command = table.concat(opts.fargs, " ")
-- Send the command to the REPL
require('iron.core').send(ft, command)
end
-- Create the primary command in Neovim
vim.api.nvim_create_user_command('IronQuiteSend', IronQuiteSend, {
nargs = '+', -- Allows for multiple arguments
})
-- Map <C-c>wd to send devtools::document command in R
vim.api.nvim_create_autocmd("FileType", {
pattern = "r",
callback = function()
vim.api.nvim_set_keymap('n', '<C-c>wd', ':IronQuiteSend devtools::document("' .. DevtoolsPath() .. '")<CR>', { noremap = true, silent = true })
end
})
-- Map <C-c>wi to send devtools::install command in R
vim.api.nvim_create_autocmd("FileType", {
pattern = "r",
callback = function()
vim.api.nvim_set_keymap('n', '<C-c>wi', ':IronQuiteSend devtools::install("' .. DevtoolsPath() .. '", upgrade = "never")<CR>', { noremap = true, silent = true })
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "r",
callback = function()
vim.api.nvim_set_keymap('n', '<C-c>i', ':IronQuiteSend install.packages("")<Left><Left>', { noremap = true, silent = true })
end
})

View File

@ -1,105 +0,0 @@
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local previewers = require("telescope.previewers")
-- Custom previewer that dynamically calculates how many lines
-- can fit in the preview window, then shows a centered slice.
local dynamic_previewer = previewers.new_buffer_previewer({
define_preview = function(self, entry, status)
-- 'entry.lnum' is the *actual file line number*.
local filepath = entry.path
local target = entry.lnum or 1
-- Get the preview buffer & window
local pbufnr = self.state.bufnr
local pwinid = status.preview_win
if not pbufnr or not vim.api.nvim_buf_is_valid(pbufnr) then
return
end
if not pwinid or not vim.api.nvim_win_is_valid(pwinid) then
return
end
-- How many lines can we show in the preview window?
-- Subtract a bit (e.g., 1 or 2) if you use borders or want extra margin.
local lines_in_window = vim.api.nvim_win_get_height(pwinid) - 1
if lines_in_window < 1 then
lines_in_window = 1
end
-- Read the entire file, figure out the slice to show
local all_lines = vim.fn.readfile(filepath)
local total = #all_lines
-- We'll center on the target line, if possible
local half_context = math.floor(lines_in_window / 2)
local start_line = math.max(target - half_context, 1)
local end_line = math.min(start_line + lines_in_window - 1, total)
-- Collect that slice of lines
local preview_lines = {}
for i = start_line, end_line do
table.insert(preview_lines, all_lines[i])
end
-- Write the slice to the preview buffer
vim.api.nvim_buf_set_lines(pbufnr, 0, -1, false, preview_lines)
vim.api.nvim_buf_clear_namespace(pbufnr, -1, 0, -1)
-- Highlight the target line within the slice
local relative_line = target - start_line + 1
if relative_line >= 1 and relative_line <= #preview_lines then
vim.api.nvim_buf_add_highlight(
pbufnr, -1, "Search", relative_line - 1, 0, -1
)
end
end,
})
local function jump_to_line()
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
local current_file = vim.api.nvim_buf_get_name(0)
local entries = {}
for i, text in ipairs(lines) do
table.insert(entries, {
value = text,
display = string.format("%d: %s", i, text),
ordinal = text,
path = current_file, -- needed by the previewer
lnum = i, -- actual file line number
})
end
pickers.new({}, {
prompt_title = "Jump to Line",
finder = finders.new_table({
results = entries,
entry_maker = function(e) return e end,
}),
sorter = conf.generic_sorter({}),
previewer = dynamic_previewer,
attach_mappings = function(prompt_bufnr, _)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
if selection then
local target_line = selection.lnum
local closed_line = vim.fn.foldclosed(target_line)
if closed_line ~= -1 then
target_line = closed_line
end
-- Jump and open the fold
vim.cmd(string.format("normal! %dG", target_line))
vim.cmd("normal! zv")
end
end)
return true
end,
}):find()
end
return { jump_to_line = jump_to_line }