You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following suggestion re installation of obsidian.nvim using lazy.nvim, I add a new table mappings within opts, but the defined shortcuts don't work.
I've ensured obsidian.nvim has been loaded by 1) opening a markdown file (and confirming that :Obsidian<tab> shows commands) and 2) disabling lazy loading.
I can set and use the keymap fine using e.g. nnoremap <leader>tc :lua require('obsidian').util.toggle_checkbox()<CR> from command line in neovim, so I could just add the required keymaps elsewhere.
But I'm curious why this mappings table isn't being loaded, and as a relative noob this has delayed me quite a lot in getting going with obsidian.nvim and I'd love to help anyone else going down the same dead end!
Config
~/.config/nvim-test/init.lua
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- add your plugins here
{
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
lazy = true,
ft = "markdown",
dependencies = {
-- Required.
"nvim-lua/plenary.nvim",
},
opts = {
workspaces = {
{
name = "personal",
path = "/home/myusername/Documents/My Notes",
},
},
mappings = {
-- Overrides the 'gf' mapping to work on markdown/wiki links within your vault.
["gf"] = {
action = function()
return require("obsidian").util.gf_passthrough()
end,
opts = { noremap = false, expr = true, buffer = true },
},
-- Toggle check-boxes.
["<leader>ch"] = {
action = function()
return require("obsidian").util.toggle_checkbox()
end,
opts = { buffer = true, desc = "Toggle checkbox" },
},
-- Smart action depending on context, either follow link or toggle checkbox.
["<cr>"] = {
action = function()
return require("obsidian").util.smart_action()
end,
opts = { buffer = true, expr = true },
},
["<leader>os"] = {
action = function()
return require("obsidian").util.ObsidianQuickSwitch()
end,
opts = { silent = true, noremap = true, desc = "[O]bsidian Quick[S]witch" },
},
},
},
},
},
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
Environment
❯ NVIM_APPNAME=nvim-test nvim --version
NVIM v0.10.1
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189
Run "nvim -V1 -v" for more info
🐛 Describe the bug
Following suggestion re installation of obsidian.nvim using lazy.nvim, I add a new table
mappings
withinopts
, but the defined shortcuts don't work.I've ensured obsidian.nvim has been loaded by 1) opening a markdown file (and confirming that
:Obsidian<tab>
shows commands) and 2) disabling lazy loading.I can set and use the keymap fine using e.g.
nnoremap <leader>tc :lua require('obsidian').util.toggle_checkbox()<CR>
from command line in neovim, so I could just add the required keymaps elsewhere.But I'm curious why this
mappings
table isn't being loaded, and as a relative noob this has delayed me quite a lot in getting going with obsidian.nvim and I'd love to help anyone else going down the same dead end!Config
~/.config/nvim-test/init.lua
Environment
The text was updated successfully, but these errors were encountered: