mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-25 11:12:22 +08:00
Compare commits
No commits in common. "5f34976cd45b60586848d5ae1caebd49951af47c" and "fb7bb8848587bec40767dc6a98ba845ade53c099" have entirely different histories.
5f34976cd4
...
fb7bb88485
@ -65,14 +65,6 @@ if vim.fn.mapcheck('[I', 'n') == '' then
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_buf_set_keymap(0, 'n', '<F2>', '', {
|
|
||||||
noremap = true,
|
|
||||||
silent = true,
|
|
||||||
nowait = true,
|
|
||||||
callback = function()
|
|
||||||
require('zettelkasten.browser').open_tag_tree()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = require('zettelkasten.config')
|
local config = require('zettelkasten.config')
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
if vim.b.did_ftp == true then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.opt_local.cursorline = true
|
|
||||||
vim.opt_local.modifiable = false
|
|
||||||
vim.opt_local.buflisted = false
|
|
||||||
vim.opt_local.number = false
|
|
||||||
vim.opt_local.relativenumber = false
|
|
||||||
vim.opt_local.bufhidden = 'wipe'
|
|
||||||
vim.opt_local.syntax = 'zktagstree'
|
|
||||||
vim.opt_local.buftype = 'nofile'
|
|
||||||
vim.opt_local.swapfile = false
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 'n', '<F2>', '', {
|
|
||||||
noremap = true,
|
|
||||||
silent = true,
|
|
||||||
nowait = true,
|
|
||||||
callback = function() end,
|
|
||||||
})
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 'n', '<Enter>', '', {
|
|
||||||
noremap = true,
|
|
||||||
silent = true,
|
|
||||||
nowait = true,
|
|
||||||
callback = function()
|
|
||||||
local bufnr = vim.fn.bufnr('zk://browser')
|
|
||||||
if vim.api.nvim_buf_is_valid(bufnr) then
|
|
||||||
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
bufnr,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
false,
|
|
||||||
require('zettelkasten').get_note_browser_content({ tags = { vim.fn.getline('.') } })
|
|
||||||
)
|
|
||||||
end
|
|
||||||
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 'n', '<LeftRelease>', '', {
|
|
||||||
noremap = true,
|
|
||||||
silent = true,
|
|
||||||
nowait = true,
|
|
||||||
callback = function()
|
|
||||||
local bufnr = vim.fn.bufnr('zk://browser')
|
|
||||||
if vim.api.nvim_buf_is_valid(bufnr) then
|
|
||||||
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
bufnr,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
false,
|
|
||||||
require('zettelkasten').get_note_browser_content({ tags = { vim.fn.getline('.') } })
|
|
||||||
)
|
|
||||||
end
|
|
||||||
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
|
||||||
end,
|
|
||||||
})
|
|
@ -17,6 +17,7 @@ local ZK_FILE_NAME_PATTERN = '%d+-%d+-%d+-%d+-%d+-%d+.md'
|
|||||||
local s_note_cache_with_file_path = {}
|
local s_note_cache_with_file_path = {}
|
||||||
local s_note_cache_with_id = {}
|
local s_note_cache_with_id = {}
|
||||||
|
|
||||||
|
|
||||||
-- list all zettelkasten notes in specific folder
|
-- list all zettelkasten notes in specific folder
|
||||||
local function get_files(folder)
|
local function get_files(folder)
|
||||||
local files = fn.split(fn.globpath(folder, '*.md'), '\\n')
|
local files = fn.split(fn.globpath(folder, '*.md'), '\\n')
|
||||||
@ -224,45 +225,21 @@ function M.get_tags()
|
|||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.browse(opt)
|
function M.browse(opt)
|
||||||
vim.cmd('edit zk://browser')
|
vim.cmd('edit zk://browser')
|
||||||
vim.opt_local.syntax = ''
|
vim.opt_local.syntax = ''
|
||||||
vim.opt_local.modifiable = true
|
vim.opt_local.modifiable = true
|
||||||
vim.api.nvim_buf_set_lines(
|
vim.api.nvim_buf_set_lines(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
false,
|
false,
|
||||||
require('zettelkasten').get_note_browser_content({ tags = opt })
|
require('zettelkasten').get_note_browser_content({ tags = opt })
|
||||||
)
|
)
|
||||||
vim.opt_local.syntax = 'zkbrowser'
|
vim.opt_local.syntax = 'zkbrowser'
|
||||||
vim.opt_local.buflisted = false
|
vim.opt_local.buflisted = false
|
||||||
vim.opt_local.modifiable = false
|
vim.opt_local.modifiable = false
|
||||||
end
|
|
||||||
local function unique_string_table(t)
|
|
||||||
local temp = {}
|
|
||||||
for _, k in ipairs(t) do
|
|
||||||
temp[k] = true
|
|
||||||
end
|
|
||||||
local rst = {}
|
|
||||||
for m, _ in pairs(temp) do
|
|
||||||
table.insert(rst, m)
|
|
||||||
end
|
|
||||||
return rst
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.open_tag_tree()
|
|
||||||
vim.cmd('30vsplit zk://tags_tree')
|
|
||||||
vim.opt_local.filetype = 'zktagstree'
|
|
||||||
vim.opt_local.modifiable = true
|
|
||||||
local lines = {}
|
|
||||||
local result = M.get_tags()
|
|
||||||
|
|
||||||
for _, tag in ipairs(result) do
|
|
||||||
table.insert(lines, tag.name)
|
|
||||||
end
|
|
||||||
vim.api.nvim_buf_set_lines(0, 0, -1, false, unique_string_table(lines))
|
|
||||||
vim.opt_local.buflisted = false
|
|
||||||
vim.opt_local.modifiable = false
|
|
||||||
end
|
|
||||||
return M
|
return M
|
||||||
|
@ -585,9 +585,6 @@ local special_statusline = {
|
|||||||
zkbrowser = function()
|
zkbrowser = function()
|
||||||
return simple_name('Zettelkasten Browser')
|
return simple_name('Zettelkasten Browser')
|
||||||
end,
|
end,
|
||||||
zktagstree = function()
|
|
||||||
return simple_name('ZkTags Tree')
|
|
||||||
end,
|
|
||||||
['vader-result'] = function()
|
['vader-result'] = function()
|
||||||
return simple_name('Vader result')
|
return simple_name('Vader result')
|
||||||
end,
|
end,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user