This commit is contained in:
Saeed Afzal
2024-09-05 09:51:17 +01:00
parent 7bd33bd2fb
commit dc2774419d
6 changed files with 70 additions and 54 deletions

View File

@@ -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]]

View File

@@ -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()<CR>", {})
end
})

View File

@@ -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]])

View File

@@ -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

View File

@@ -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", "<leader>ff", builtin.fd)
map("n", "<leader>fw", builtin.live_grep)
map("n", "<leader>fb", builtin.buffers)
map("n", "<C-f>", builtin.current_buffer_fuzzy_find)
-- Visual word highlight
map("v", "<C-f>", "y<ESC>:Telescope current_buffer_fuzzy_find default_text=<c-r>0<CR>")
map("v", "<leader>fw", "y<ESC>:Telescope live_grep default_text=<c-r>0<CR>")
map("v", "<leader>ff", "y<ESC>:Telescope fd default_text=<c-r>0<CR>")
end
}

View File

@@ -1,8 +0,0 @@
return {
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {
style = "night"
}
}