28072024
This commit is contained in:
parent
3364fcbd57
commit
6e16a81d2c
4 changed files with 98 additions and 91 deletions
|
@ -28,12 +28,12 @@
|
|||
"nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" },
|
||||
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "82ba116bbd0cc5f0482783d67ea969595e2b381b" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "f97e0de0053df1cb3b9f74b9b1239acced1b7d9a" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "48d0e82f9434691cc50d970898142a8c084a49d6" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "2d5133f67429f82547ea5fad33a0b1e7d4f78a1c" },
|
||||
"nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "a2af6aa13a2ad3ad361d562a319a91bcd68c43a4" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" },
|
||||
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
||||
"tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" },
|
||||
|
|
|
@ -13,8 +13,7 @@ local config = function()
|
|||
focusable = true,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
|
||||
source = true,
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
|
|
|
@ -42,8 +42,9 @@ ins_right({
|
|||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "No Active Lsp"
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
-- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local buf_ft = vim.bo.filetype
|
||||
local clients = vim.lsp.get_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
|
|
|
@ -1,50 +1,44 @@
|
|||
local finders = require('telescope.finders')
|
||||
local previewers = require('telescope.previewers')
|
||||
local action_state = require('telescope.actions.state')
|
||||
local conf = require('telescope.config').values
|
||||
local pickers = require('telescope.pickers')
|
||||
local finders = require("telescope.finders")
|
||||
local previewers = require("telescope.previewers")
|
||||
local action_state = require("telescope.actions.state")
|
||||
local conf = require("telescope.config").values
|
||||
local pickers = require("telescope.pickers")
|
||||
local actions = require("telescope.actions")
|
||||
local mapvimkey = require("utils.keymapper").mapvimkey
|
||||
|
||||
local M = {}
|
||||
|
||||
-- local function paste_titled_link()
|
||||
-- return function(prompt_bufnr)
|
||||
-- actions.close(prompt_bufnr)
|
||||
-- local selection = action_state.get_selected_entry()
|
||||
-- local parts = vim.split(selection.value, ":")
|
||||
-- local filename_part = parts[1]
|
||||
-- local title = parts[#parts]:match("^%s*(.-)%s*$")
|
||||
-- local link = "[" .. title .. "](../" .. filename_part .. ")"
|
||||
-- vim.api.nvim_put({ link }, "", true, true)
|
||||
-- end
|
||||
-- end
|
||||
local function paste_titled_link()
|
||||
return function(prompt_bufnr)
|
||||
actions.close(prompt_bufnr)
|
||||
local selection = action_state.get_selected_entry()
|
||||
local parts = vim.split(selection.value, ":")
|
||||
local filename_part = parts[1]
|
||||
local filename_and_category = vim.split(filename_part, "/")
|
||||
local title = parts[#parts]:match("^%s*(.-)%s*$")
|
||||
local link = "["
|
||||
.. title
|
||||
.. "](../"
|
||||
.. filename_and_category[#filename_and_category - 1]
|
||||
.. "/"
|
||||
.. filename_and_category[#filename_and_category]
|
||||
.. ")"
|
||||
vim.api.nvim_put({ link }, "", true, true)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- local function paste_link()
|
||||
-- return function(prompt_bufnr)
|
||||
-- actions.close(prompt_bufnr)
|
||||
-- local selection = action_state.get_selected_entry()
|
||||
-- print(selection.value)
|
||||
-- local filename_part = vim.split(selection.value, ":")[1]
|
||||
-- local link = "[[../" .. filename_part .. "]]"
|
||||
-- vim.api.nvim_put({ link }, "", true, true)
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- M.search_title = function()
|
||||
-- require("telescope.builtin").live_grep({
|
||||
-- cwd = "~/Dropbox/TextSync/NOTES/",
|
||||
-- prompt_title = "Search by zettel title",
|
||||
-- default_text = "^raw_title: ",
|
||||
-- attach_mappings = function(_, map)
|
||||
-- map("n", "<c-i>", paste_titled_link())
|
||||
-- map("i", "<c-i>", paste_titled_link())
|
||||
-- map("n", "<c-u>", paste_link())
|
||||
-- map("i", "<c-u>", paste_link())
|
||||
-- return true
|
||||
-- end,
|
||||
-- })
|
||||
-- end
|
||||
--
|
||||
-- M.copy_filename_to_clipboard = function(prompt_bufnr)
|
||||
-- local selection = action_state.get_selected_entry()
|
||||
-- local filename_part = vim.split(selection.value, ":")[1]
|
||||
|
@ -55,66 +49,79 @@ local M = {}
|
|||
-- end
|
||||
|
||||
M.search_raw_title = function(opts)
|
||||
opts = opts or {}
|
||||
local search_dir = opts.search_dir or "."
|
||||
opts = opts or {}
|
||||
local search_dir = opts.search_dir or "."
|
||||
|
||||
pickers.new(opts, {
|
||||
prompt_title = "Search ETON",
|
||||
finder = finders.new_job(function(prompt)
|
||||
if not prompt then
|
||||
return nil
|
||||
end
|
||||
pickers
|
||||
.new(opts, {
|
||||
prompt_title = "Search ETON",
|
||||
finder = finders.new_job(function(prompt)
|
||||
if not prompt then
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Adjust the rg command to search for raw_title in all files
|
||||
local cmd = { "rg", "--no-heading", "--color=never", "--with-filename", "--line-number", "-i", "raw_title:.*" .. prompt, search_dir }
|
||||
return cmd
|
||||
end, opts.entry_maker or function(entry)
|
||||
local filename, lnum, raw_title = entry:match("([^:]+):(%d+):raw_title:(.*)")
|
||||
if not filename then return nil end
|
||||
-- Adjust the rg command to search for raw_title in all files
|
||||
local cmd = {
|
||||
"rg",
|
||||
"--no-heading",
|
||||
"--color=never",
|
||||
"--with-filename",
|
||||
"--line-number",
|
||||
"-i",
|
||||
"raw_title:.*" .. prompt,
|
||||
search_dir,
|
||||
}
|
||||
return cmd
|
||||
end, opts.entry_maker or function(entry)
|
||||
local filename, lnum, raw_title = entry:match("([^:]+):(%d+):raw_title:(.*)")
|
||||
if not filename then
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Получаем только базовое имя файла
|
||||
local basename = filename:match("^.+/(.+)$") or filename
|
||||
-- Получаем только базовое имя файла
|
||||
local basename = filename:match("^.+/(.+)$") or filename
|
||||
|
||||
return {
|
||||
value = entry,
|
||||
ordinal = basename .. " " .. (raw_title or ""),
|
||||
display = basename .. " - " .. (raw_title or ""),
|
||||
filename = filename,
|
||||
lnum = tonumber(lnum),
|
||||
}
|
||||
end),
|
||||
previewer = previewers.new_buffer_previewer({
|
||||
define_preview = function(self, entry, status)
|
||||
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
|
||||
bufname = self.state.bufname,
|
||||
winid = self.state.winid,
|
||||
preview = self.state.preview
|
||||
})
|
||||
vim.api.nvim_buf_call(self.state.bufnr, function()
|
||||
vim.fn.cursor(entry.lnum, 0)
|
||||
vim.cmd("normal! zz")
|
||||
end)
|
||||
end
|
||||
}),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(_, map)
|
||||
actions.select_default:replace(function()
|
||||
local selection = action_state.get_selected_entry()
|
||||
actions.close(_)
|
||||
vim.cmd('edit ' .. selection.filename)
|
||||
vim.fn.cursor(selection.lnum, 0)
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
}):find()
|
||||
return {
|
||||
value = entry,
|
||||
ordinal = basename .. " " .. (raw_title or ""),
|
||||
display = basename .. " - " .. (raw_title or ""),
|
||||
filename = filename,
|
||||
lnum = tonumber(lnum),
|
||||
}
|
||||
end),
|
||||
previewer = previewers.new_buffer_previewer({
|
||||
define_preview = function(self, entry, status)
|
||||
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
|
||||
bufname = self.state.bufname,
|
||||
winid = self.state.winid,
|
||||
preview = self.state.preview,
|
||||
})
|
||||
-- vim.api.nvim_buf_call(self.state.bufnr, function()
|
||||
-- vim.fn.cursor(entry.lnum, 0)
|
||||
-- vim.cmd("normal! zz")
|
||||
-- end)
|
||||
end,
|
||||
}),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(_, map)
|
||||
-- map("n", "<c-i>", paste_titled_link())
|
||||
-- map("i", "<c-i>", paste_titled_link())
|
||||
map("n", "<c-u>", paste_titled_link())
|
||||
map("i", "<c-u>", paste_titled_link())
|
||||
actions.select_default:replace(function()
|
||||
local selection = action_state.get_selected_entry()
|
||||
actions.close(_)
|
||||
vim.cmd("vsplit " .. selection.filename)
|
||||
vim.fn.cursor(selection.lnum, 0)
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
end
|
||||
|
||||
-- vim.api.nvim_create_user_command("SearchZettelTitle", M.search_title, {})
|
||||
-- mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
|
||||
|
||||
-- vim.api.nvim_create_user_command("SearchZettelTitle", M.search_raw_title({search_dir='/Users/fz0x1/Dropbox/TextSync/NOTES/01-zettel/'}), {})
|
||||
vim.api.nvim_create_user_command("SearchZettelTitle", function()
|
||||
M.search_raw_title({ search_dir = '/Users/fz0x1/Dropbox/TextSync/NOTES/01-zettel/' })
|
||||
M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/NOTES/01-zettel/" })
|
||||
end, {})
|
||||
mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue