Add Obsidian

This commit is contained in:
Thomas Avé 2024-01-21 12:24:56 +01:00
parent 2dbba249da
commit 6279959615
5 changed files with 110 additions and 70 deletions

View File

@ -25,6 +25,7 @@
"nvim-tree.lua": { "branch": "master", "commit": "59e65d88db177ad1e6a8cffaafd4738420ad20b6" }, "nvim-tree.lua": { "branch": "master", "commit": "59e65d88db177ad1e6a8cffaafd4738420ad20b6" },
"nvim-treesitter": { "branch": "master", "commit": "07c8c3d84f67b1530f636dcad31971f569a3df5f" }, "nvim-treesitter": { "branch": "master", "commit": "07c8c3d84f67b1530f636dcad31971f569a3df5f" },
"nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
"obsidian.nvim": { "branch": "main", "commit": "e2d6ce7b07941b0788177e1297699ad99c1470dc" },
"oil.nvim": { "branch": "master", "commit": "dd432e76d01eda08b8658415588d011009478469" }, "oil.nvim": { "branch": "master", "commit": "dd432e76d01eda08b8658415588d011009478469" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" }, "sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" },

View File

@ -0,0 +1,37 @@
local function open_link()
local util = require("obsidian.util")
if util.cursor_on_markdown_link(nil, nil, true) then
vim.cmd("ObsidianFollowLink")
else
util.toggle_checkbox()
end
end
return {
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
ft = "markdown",
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
-- event = {
-- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'.
-- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md"
-- "BufReadPre path/to/my-vault/**.md",
-- "BufNewFile path/to/my-vault/**.md",
-- },
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
workspaces = {
{
name = "Lumentis",
path = "~/Workspace/DnD/Lumentis Campaign Setting/",
},
},
disable_frontmatter = true,
},
keys = {
{"<cr>", open_link, ft = "markdown" },
{"gd", open_link, ft = "markdown" },
{"<leader>rn", ":ObsidianRename<cr>"},
},
detect_cwd = true,
}

View File

@ -3,7 +3,7 @@ return {
dependencies = {'luckasRanarison/tree-sitter-hypr'}, dependencies = {'luckasRanarison/tree-sitter-hypr'},
build = ":TSUpdate", build = ":TSUpdate",
opts = { opts = {
ensure_installed = { "cpp", "c", "lua", "vim", "dockerfile", "python", "java", "cmake", "diff", "gitcommit", "html", "css", "javascript", "json", "rust", "sql", "yaml" }, ensure_installed = { "cpp", "c", "lua", "vim", "dockerfile", "python", "java", "cmake", "diff", "gitcommit", "html", "css", "javascript", "json", "rust", "sql", "yaml", "markdown", "markdown_inline" },
auto_install = true, auto_install = true,
highlight = { highlight = {
enable = true, enable = true,

View File

@ -1,69 +1,70 @@
local pickers = require("telescope.pickers") return {}
local actions = require "telescope.actions" -- local pickers = require("telescope.pickers")
local action_state = require("telescope.actions.state") -- local actions = require "telescope.actions"
local finders = require("telescope.finders") -- local action_state = require("telescope.actions.state")
local conf = require("telescope.config").values -- local finders = require("telescope.finders")
-- local conf = require("telescope.config").values
local root_path = '/home/user/Workspace/DnD/Lumentis Campaign Setting' --
-- local root_path = '/home/user/Workspace/DnD/Lumentis Campaign Setting'
local function get_title(file) --
for line in io.lines(file) do -- local function get_title(file)
line = string.gsub(line, "#", "") -- for line in io.lines(file) do
line = string.gsub(line, "^%s*", "") -- line = string.gsub(line, "#", "")
line = string.gsub(line, "%s*$", "") -- line = string.gsub(line, "^%s*", "")
return line -- line = string.gsub(line, "%s*$", "")
end -- return line
end -- end
-- end
local function choose_link(opts, titles, links) --
opts = opts or {} -- local function choose_link(opts, titles, links)
pickers.new(opts, { -- opts = opts or {}
prompt_title = "Choose a file", -- pickers.new(opts, {
finder = finders.new_table { -- prompt_title = "Choose a file",
results = titles -- finder = finders.new_table {
}, -- results = titles
sorter = conf.generic_sorter(opts), -- },
attach_mappings = function(prompt_bufnr, _) -- sorter = conf.generic_sorter(opts),
actions.select_default:replace(function() -- attach_mappings = function(prompt_bufnr, _)
actions.close(prompt_bufnr) -- actions.select_default:replace(function()
local selection = action_state.get_selected_entry() -- actions.close(prompt_bufnr)
vim.api.nvim_put({ links[selection['index']] }, "", false, true) -- local selection = action_state.get_selected_entry()
end) -- vim.api.nvim_put({ links[selection['index']] }, "", false, true)
return true -- end)
end, -- return true
}):find() -- end,
end -- }):find()
-- end
local function insert_link() --
local scan = require("plenary.scandir").scan_dir(root_path) -- local function insert_link()
local titles = {} -- local scan = require("plenary.scandir").scan_dir(root_path)
local links = {} -- local titles = {}
for _, v in ipairs(scan) do -- local links = {}
if v:match("^.+(%..+)$") == ".md" then -- for _, v in ipairs(scan) do
local absolute_filename = string.sub(v, root_path:len()+1, v:len()) -- if v:match("^.+(%..+)$") == ".md" then
local title = get_title(v) -- local absolute_filename = string.sub(v, root_path:len()+1, v:len())
if title:len() > 0 then -- local title = get_title(v)
local link = "[" .. title .. "](" .. absolute_filename .. ")" -- if title:len() > 0 then
table.insert(titles, title) -- local link = "[" .. title .. "](" .. absolute_filename .. ")"
table.insert(links, link) -- table.insert(titles, title)
end -- table.insert(links, link)
end -- end
end -- end
choose_link(require("telescope.themes").get_dropdown{}, titles, links) -- end
end -- choose_link(require("telescope.themes").get_dropdown{}, titles, links)
-- end
return { --
'vimwiki/vimwiki', -- return {
dependencies = {'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim'}, -- 'vimwiki/vimwiki',
init = function () -- dependencies = {'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim'},
vim.g.vimwiki_list = {{path = '~/Workspace/DnD/Lumentis Campaign Setting/', syntax = 'markdown', ext = '.md'}} -- init = function ()
vim.g.vimwiki_key_mappings = { table_mappings = 0 } -- vim.g.vimwiki_list = {{path = '~/Workspace/DnD/Lumentis Campaign Setting/', syntax = 'markdown', ext = '.md'}}
vim.g.vimwiki_markdown_link_ext = 1 -- vim.g.vimwiki_key_mappings = { table_mappings = 0 }
vim.g.vimwiki_global_ext = 0 -- vim.g.vimwiki_markdown_link_ext = 1
end, -- vim.g.vimwiki_global_ext = 0
lazy = false, -- end,
keys = { -- lazy = false,
{"<leader>l", insert_link}, -- keys = {
{"<leader>l", insert_link, mode="i"} -- {"<leader>l", insert_link},
} -- {"<leader>l", insert_link, mode="i"}
} -- }
-- }

View File

@ -38,6 +38,7 @@ vim.g.rooter_patterns = {".git", "Makefile", "CMakeLists.txt", "build/", "meson.
vim.g.rooter_silent_chdir = 1 vim.g.rooter_silent_chdir = 1
vim.opt.shada = "!,'2000,f1,<50,s10,h" vim.opt.shada = "!,'2000,f1,<50,s10,h"
vim.o.updatetime = 250 vim.o.updatetime = 250
vim.opt.conceallevel = 1
-- Vimtex -- Vimtex
vim.g.tex_flavor = 'latex' vim.g.tex_flavor = 'latex'