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-treesitter": { "branch": "master", "commit": "07c8c3d84f67b1530f636dcad31971f569a3df5f" },
"nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
"obsidian.nvim": { "branch": "main", "commit": "e2d6ce7b07941b0788177e1297699ad99c1470dc" },
"oil.nvim": { "branch": "master", "commit": "dd432e76d01eda08b8658415588d011009478469" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"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'},
build = ":TSUpdate",
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,
highlight = {
enable = true,

View File

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