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-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" },
|
"nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" },
|
||||||
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
|
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "82ba116bbd0cc5f0482783d67ea969595e2b381b" },
|
"nvim-tree.lua": { "branch": "master", "commit": "48d0e82f9434691cc50d970898142a8c084a49d6" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "f97e0de0053df1cb3b9f74b9b1239acced1b7d9a" },
|
"nvim-treesitter": { "branch": "master", "commit": "2d5133f67429f82547ea5fad33a0b1e7d4f78a1c" },
|
||||||
"nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" },
|
"nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" },
|
||||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" },
|
"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" },
|
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
||||||
"tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" },
|
"tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" },
|
||||||
|
|
|
@ -13,8 +13,7 @@ local config = function()
|
||||||
focusable = true,
|
focusable = true,
|
||||||
style = "minimal",
|
style = "minimal",
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
source = "always",
|
source = true,
|
||||||
|
|
||||||
header = "",
|
header = "",
|
||||||
prefix = "",
|
prefix = "",
|
||||||
},
|
},
|
||||||
|
|
|
@ -42,8 +42,9 @@ ins_right({
|
||||||
-- Lsp server name .
|
-- Lsp server name .
|
||||||
function()
|
function()
|
||||||
local msg = "No Active Lsp"
|
local msg = "No Active Lsp"
|
||||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
-- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||||
local clients = vim.lsp.get_active_clients()
|
local buf_ft = vim.bo.filetype
|
||||||
|
local clients = vim.lsp.get_clients()
|
||||||
if next(clients) == nil then
|
if next(clients) == nil then
|
||||||
return msg
|
return msg
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,50 +1,44 @@
|
||||||
local finders = require('telescope.finders')
|
local finders = require("telescope.finders")
|
||||||
local previewers = require('telescope.previewers')
|
local previewers = require("telescope.previewers")
|
||||||
local action_state = require('telescope.actions.state')
|
local action_state = require("telescope.actions.state")
|
||||||
local conf = require('telescope.config').values
|
local conf = require("telescope.config").values
|
||||||
local pickers = require('telescope.pickers')
|
local pickers = require("telescope.pickers")
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
local mapvimkey = require("utils.keymapper").mapvimkey
|
local mapvimkey = require("utils.keymapper").mapvimkey
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- local function paste_titled_link()
|
local function paste_titled_link()
|
||||||
-- return function(prompt_bufnr)
|
return function(prompt_bufnr)
|
||||||
-- actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
-- local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
-- local parts = vim.split(selection.value, ":")
|
local parts = vim.split(selection.value, ":")
|
||||||
-- local filename_part = parts[1]
|
local filename_part = parts[1]
|
||||||
-- local title = parts[#parts]:match("^%s*(.-)%s*$")
|
local filename_and_category = vim.split(filename_part, "/")
|
||||||
-- local link = "[" .. title .. "](../" .. filename_part .. ")"
|
local title = parts[#parts]:match("^%s*(.-)%s*$")
|
||||||
-- vim.api.nvim_put({ link }, "", true, true)
|
local link = "["
|
||||||
-- end
|
.. title
|
||||||
-- end
|
.. "](../"
|
||||||
|
.. 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()
|
-- local function paste_link()
|
||||||
-- return function(prompt_bufnr)
|
-- return function(prompt_bufnr)
|
||||||
-- actions.close(prompt_bufnr)
|
-- actions.close(prompt_bufnr)
|
||||||
-- local selection = action_state.get_selected_entry()
|
-- local selection = action_state.get_selected_entry()
|
||||||
|
-- print(selection.value)
|
||||||
-- local filename_part = vim.split(selection.value, ":")[1]
|
-- local filename_part = vim.split(selection.value, ":")[1]
|
||||||
-- local link = "[[../" .. filename_part .. "]]"
|
-- local link = "[[../" .. filename_part .. "]]"
|
||||||
-- vim.api.nvim_put({ link }, "", true, true)
|
-- vim.api.nvim_put({ link }, "", true, true)
|
||||||
-- end
|
-- end
|
||||||
-- 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)
|
-- M.copy_filename_to_clipboard = function(prompt_bufnr)
|
||||||
-- local selection = action_state.get_selected_entry()
|
-- local selection = action_state.get_selected_entry()
|
||||||
-- local filename_part = vim.split(selection.value, ":")[1]
|
-- local filename_part = vim.split(selection.value, ":")[1]
|
||||||
|
@ -58,7 +52,8 @@ M.search_raw_title = function(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local search_dir = opts.search_dir or "."
|
local search_dir = opts.search_dir or "."
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
|
.new(opts, {
|
||||||
prompt_title = "Search ETON",
|
prompt_title = "Search ETON",
|
||||||
finder = finders.new_job(function(prompt)
|
finder = finders.new_job(function(prompt)
|
||||||
if not prompt then
|
if not prompt then
|
||||||
|
@ -66,11 +61,22 @@ M.search_raw_title = function(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Adjust the rg command to search for raw_title in all files
|
-- 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 }
|
local cmd = {
|
||||||
|
"rg",
|
||||||
|
"--no-heading",
|
||||||
|
"--color=never",
|
||||||
|
"--with-filename",
|
||||||
|
"--line-number",
|
||||||
|
"-i",
|
||||||
|
"raw_title:.*" .. prompt,
|
||||||
|
search_dir,
|
||||||
|
}
|
||||||
return cmd
|
return cmd
|
||||||
end, opts.entry_maker or function(entry)
|
end, opts.entry_maker or function(entry)
|
||||||
local filename, lnum, raw_title = entry:match("([^:]+):(%d+):raw_title:(.*)")
|
local filename, lnum, raw_title = entry:match("([^:]+):(%d+):raw_title:(.*)")
|
||||||
if not filename then return nil end
|
if not filename then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Получаем только базовое имя файла
|
-- Получаем только базовое имя файла
|
||||||
local basename = filename:match("^.+/(.+)$") or filename
|
local basename = filename:match("^.+/(.+)$") or filename
|
||||||
|
@ -88,33 +94,34 @@ M.search_raw_title = function(opts)
|
||||||
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
|
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
|
||||||
bufname = self.state.bufname,
|
bufname = self.state.bufname,
|
||||||
winid = self.state.winid,
|
winid = self.state.winid,
|
||||||
preview = self.state.preview
|
preview = self.state.preview,
|
||||||
})
|
})
|
||||||
vim.api.nvim_buf_call(self.state.bufnr, function()
|
-- vim.api.nvim_buf_call(self.state.bufnr, function()
|
||||||
vim.fn.cursor(entry.lnum, 0)
|
-- vim.fn.cursor(entry.lnum, 0)
|
||||||
vim.cmd("normal! zz")
|
-- vim.cmd("normal! zz")
|
||||||
end)
|
-- end)
|
||||||
end
|
end,
|
||||||
}),
|
}),
|
||||||
sorter = conf.generic_sorter(opts),
|
sorter = conf.generic_sorter(opts),
|
||||||
attach_mappings = function(_, map)
|
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()
|
actions.select_default:replace(function()
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
actions.close(_)
|
actions.close(_)
|
||||||
vim.cmd('edit ' .. selection.filename)
|
vim.cmd("vsplit " .. selection.filename)
|
||||||
vim.fn.cursor(selection.lnum, 0)
|
vim.fn.cursor(selection.lnum, 0)
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}):find()
|
})
|
||||||
|
:find()
|
||||||
end
|
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()
|
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, {})
|
end, {})
|
||||||
mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
|
mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue