diff --git a/init.lua b/init.lua index 4e514d9..2bef534 100644 --- a/init.lua +++ b/init.lua @@ -18,8 +18,5 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- Init plugins +-- Load plugins require("lazy").setup("plugins") - --- Theme -vim.cmd [[colorscheme tokyonight]] diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 8a43507..3be0ad4 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -9,7 +9,7 @@ api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { pattern = { "*.go" }, callback = function() vim.cmd [[Tabs 4]] - command = "compiler go" + vim.cmd [[compiler go]] end }) @@ -17,3 +17,30 @@ api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { pattern = { "*.ts", "*.tsx" }, command = "compiler tsc" }) + +-- Markdown navigation +function navigate_markdown() + local line = vim.api.nvim_get_current_line() + local cursor_pos = vim.api.nvim_win_get_cursor(0) + local col = cursor_pos[2] + + local pattern = "%[%[([^%]]+%.md)%]%]" + local start_pos, end_pos, file = line:find(pattern) + + if start_pos and col >= start_pos - 1 and col <= end_pos then + if vim.fn.filereadable(file) == 1 then + vim.cmd('edit ' .. file) + else + print("File not found: " .. file) + end + else + print("No valid Markdown link under cursor.") + end +end + +api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + api.nvim_set_keymap("n", "gd", ":lua navigate_markdown()", {}) + end +}) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 589efe1..04ddaad 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -2,7 +2,6 @@ local g, opt, cmd = vim.g, vim.opt, vim.cmd -- Settings g.mapleader = " " -g.maplocalleader = "," opt.backup = false opt.swapfile = false @@ -19,8 +18,6 @@ opt.splitbelow = true opt.splitright = true opt.showmode = false -opt.grepprg = "rg --vimgrep --smart-case" - opt.path = ".,**" cmd "set path-=node_modules/**" cmd "set wildignore-=*/node_modules/*" @@ -34,7 +31,13 @@ opt.list = true opt.listchars = "lead:·,tab:··" -- Search -vim.opt.ignorecase = true -vim.opt.smartcase = true -vim.opt.hlsearch = true -vim.opt.incsearch = true +opt.ignorecase = true +opt.smartcase = true +opt.hlsearch = true +opt.incsearch = true + +-- Transparency +vim.cmd([[highlight Normal guibg=none]]) +vim.cmd([[highlight NonText guibg=none]]) +vim.cmd([[highlight Normal ctermbg=none]]) +vim.cmd([[highlight NonText ctermbg=none]]) diff --git a/lua/markdown_navigator/init.lua b/lua/markdown_navigator/init.lua new file mode 100644 index 0000000..001eb15 --- /dev/null +++ b/lua/markdown_navigator/init.lua @@ -0,0 +1,31 @@ +local M = {} + +function M.open() + local line = vim.api.nvim_get_current_line() + local cursor_pos = vim.api.nvim_win_get_cursor(0) + local col = cursor_pos[2] + + local pattern = "%[%[([^%]]+%.md)%]%]" + local start_pos, end_pos, file = line:find(pattern) + + if start_pos and col >= start_pos - 1 and col <= end_pos then + if vim.fn.filereadable(file) == 1 then + vim.cmd('edit ' .. file) + else + print("File not found: " .. file) + end + else + print("No valid Markdown link under cursor.") + end +end + +function M.setup() + vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + vim.api.nvim_set_keymap("n", "gd", ":lua require('markdown_navigator').open()", {}) + end + }) +end + +return M diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua deleted file mode 100644 index 559d40a..0000000 --- a/lua/plugins/telescope.lua +++ /dev/null @@ -1,34 +0,0 @@ -local function map(mode, lhs, rhs) - vim.keymap.set(mode, lhs, rhs, {}) -end - -return { - "nvim-telescope/telescope.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" } - }, - config = function() - local telescope = require("telescope") - local builtin = require("telescope.builtin") - - telescope.setup { - defaults = { - layout_config = { prompt_position = "top" }, - sorting_strategy = "ascending" - } - } - - telescope.load_extension("fzf") - - map("n", "ff", builtin.fd) - map("n", "fw", builtin.live_grep) - map("n", "fb", builtin.buffers) - map("n", "", builtin.current_buffer_fuzzy_find) - - -- Visual word highlight - map("v", "", "y:Telescope current_buffer_fuzzy_find default_text=0") - map("v", "fw", "y:Telescope live_grep default_text=0") - map("v", "ff", "y:Telescope fd default_text=0") - end -} diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua deleted file mode 100644 index 8753a8f..0000000 --- a/lua/plugins/tokyonight.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "folke/tokyonight.nvim", - lazy = false, - priority = 1000, - opts = { - style = "night" - } -}