blink.cmp, oil.nvim, syss-report-selector

This commit is contained in:
Christopher Beckmann
2024-12-20 17:40:07 +01:00
parent 310b6c4d25
commit 39551b1831
14 changed files with 422 additions and 256 deletions

View File

@@ -1,30 +1,26 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "cdbf6f41381e5ee4810b4b09284b603d8f18365d" },
"catppuccin": { "branch": "main", "commit": "fc537040147f0374a22b88142a20eb6781141f0b" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"blink.cmp": { "branch": "main", "commit": "bff6c0f06bdc1114c5816b0f6b19ad6a7e15a638" },
"catppuccin": { "branch": "main", "commit": "faf15ab0201b564b6368ffa47b56feefc92ce3f4" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
"lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "ddefe5ab051e7ca6a7b374754f0920c44668b54f" },
"mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" },
"noice.nvim": { "branch": "main", "commit": "7b1960c48078a8b2fb44a89db82f4fa637b2d7c8" },
"nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" },
"nvim-highlight-colors": { "branch": "main", "commit": "231547093a788b925b8fc36351ad422701c3a8c8" },
"nvim-lspconfig": { "branch": "master", "commit": "2b361e043810d5587d9af0787f8ce40da92ec5e9" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "2daa8921b7afdcfa47419a21ea343c3df6d74fa0" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.icons": { "branch": "main", "commit": "44c0160526f7ae17ca8e8eab9ab235d047fcf7a6" },
"noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-highlight-colors": { "branch": "main", "commit": "e967e2ba13fd4ca731b41d0e5cc1ac2edcd6e25e" },
"nvim-lspconfig": { "branch": "master", "commit": "040001d85e9190a904d0e35ef5774633e14d8475" },
"nvim-scrollbar": { "branch": "main", "commit": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49" },
"nvim-tree.lua": { "branch": "master", "commit": "53b0bcaadaffb505acff230578b56a86ec1ab38a" },
"nvim-treesitter": { "branch": "master", "commit": "dfd4fb330f75595813e2a2f83000580a36dd10ff" },
"nvim-web-devicons": { "branch": "master", "commit": "3fafeea5f339223e888fd15eb4032260849cb038" },
"plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" },
"snacks.nvim": { "branch": "main", "commit": "9651a931043359fcc094ab5c67ac22554a602745" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" },
"vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" }
}
"nvim-treesitter": { "branch": "master", "commit": "2405274937718d520a40e03df92030dca6b4f0fd" },
"nvim-web-devicons": { "branch": "master", "commit": "0eb18da56e2ba6ba24de7130a12bcc4e31ad11cb" },
"oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"snacks.nvim": { "branch": "main", "commit": "98df370703b3c47a297988f3e55ce99628639590" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"vim-tmux-navigator": { "branch": "master", "commit": "424b5caa154bff34dc258ee53cec5a8e36cf7ea8" }
}

View File

@@ -7,3 +7,15 @@ for _, style in ipairs({ "compact", "fancy", "minimal" }) do
)
end
end
local list_snips = function()
Snacks.notifier.notify(vim.o.filetype, "debug")
local ft_list = require("luasnip").available()[vim.o.filetype]
-- local ft_list = require("luasnip").available()[vim.o.filetype]
local ft_snips = {}
for _, item in pairs(ft_list) do
ft_snips[item.trigger] = item.name
end
print(vim.inspect(ft_snips))
end
vim.api.nvim_create_user_command("SnipList", list_snips, {})

View File

@@ -11,6 +11,10 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
local opts = {}
local opts = {
dev = {
path = "~/.config/nvim/lua/"
}
}
require("lazy").setup("kamu.plugins", opts)

View File

@@ -1,37 +1,95 @@
local function check_backspace()
local col = vim.fn.col(".") - 1
if col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then
return true
else
return false
end
end
local function T(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
-- local function check_backspace()
-- local col = vim.fn.col(".") - 1
-- if col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then
-- return true
-- else
-- return false
-- end
-- end
--
-- local function T(str)
-- return vim.api.nvim_replace_termcodes(str, true, true, true)
-- end
return {
{
'hrsh7th/nvim-cmp',
'saghen/blink.cmp',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'onsails/lspkind.nvim',
{ 'L3MON4D3/LuaSnip', build = "make install_jsregexp" },
'saadparwaiz1/cmp_luasnip',
{ 'L3MON4D3/LuaSnip', version = 'v2.*' },
'rafamadriz/friendly-snippets',
{
"folke/lazydev.nvim", -- https://github.com/folke/lazydev.nvim
ft = "lua",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
},
lazy = false,
priority = 100,
config = function()
build = 'cargo build --release',
opts = {
keymap = { preset = 'super-tab' },
appearance = {
use_nvim_cmp_as_default = false,
nerd_font_variant = 'mono',
},
completion = {
accept = {
auto_brackets = {
enabled = true,
},
},
menu = {
draw = {
treesitter = { "lsp" },
},
},
documentation = {
auto_show = true,
auto_show_delay_ms = 200,
},
},
signature = { enabled = true },
sources = {
default = { 'lsp', 'path', 'luasnip', 'buffer' },
per_filetype = {
tex = { 'lsp', 'path', 'luasnip', 'buffer' },
lua = { 'lsp', 'path', 'luasnip', 'buffer', 'lazydev' },
},
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
fallbacks = { "lsp" },
},
luasnip = {
name = 'Luasnip',
module = 'blink.cmp.sources.luasnip',
opts = {
use_show_condition = true,
show_autosnippets = true,
}
},
},
},
snippets = {
expand = function(snippet) require('luasnip').lsp_expand(snippet) end,
active = function(filter)
if filter and filter.direction then
return require('luasnip').jumpable(filter.direction)
end
return require('luasnip').in_snippet()
end,
jump = function(direction) require('luasnip').jump(direction) end,
},
},
config = function(_, opts)
vim.opt.completeopt = { "menu", "menuone" }
local lspkind = require('lspkind')
local cmp = require('cmp')
--- LuaSnip
local ls = require("luasnip")
ls.setup({
history = true,
@@ -39,116 +97,156 @@ return {
ls.filetype_extend("latex", { "tex" })
-- require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_lua").load({
-- paths = vim.api.nvim_get_runtime_file("lua/kamu/snippets/", true)[1]
paths = "~/.config/nvim/lua/kamu/snippets/",
})
-- require("luasnip.loaders").edit_snippet_files()
-- vim.keymap.set({ "i", "s" }, "<Tab>", function()
-- if ls.expand_or_jumpable() then
-- ls.expand_or_jump()
-- else
-- return "<Tab>"
-- end
-- end, { expr = true, silent = true })
--
-- vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
-- if ls.jumpable(-1) then
-- ls.jump(-1)
-- else
-- print("can't go further back")
-- end
-- end, { silent = true })
cmp.setup({
formatting = {
format = lspkind.cmp_format({
mode = 'symbol_text',
}),
},
ellipsis_char = '...',
show_labelDetails = true,
snippet = {
expand = function(args)
-- vim.snippet.expand(args.body)
require('luasnip').lsp_expand(args.body)
end,
},
maxwidth = {
menu = 50,
abbr = 50,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
-- ['<Tab>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<Tab>'] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(T('<C-n>'), 'n')
elseif ls.expand_or_jumpable() then
ls.expand_or_jump()
elseif not check_backspace() then
cmp.mapping.complete()(core, fallback)
else
vim.cmd(':>')
vim.cmd(':startinsert')
end
end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(T('<C-p>'), 'n')
elseif ls.jumpable(-1) then
ls.jump(-1)
else
vim.cmd(':<')
vim.cmd(':startinsert')
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer' },
}),
paths = { vim.fn.stdpath("config") .. "/lua/kamu/snippets/" },
})
-- Set configuration for specific filetype.
-- cmp.setup.filetype('gitcommit', {
-- sources = cmp.config.sources({
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
-- }, {
-- { name = 'buffer' },
-- })
-- })
-- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
-- cmp.setup.cmdline({ '/', '?' }, {
-- mapping = cmp.mapping.preset.cmdline(),
-- sources = {
-- { name = 'buffer' }
-- }
-- })
--
-- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
-- cmp.setup.cmdline(':', {
-- mapping = cmp.mapping.preset.cmdline(),
-- sources = cmp.config.sources({
-- { name = 'path' }
-- }, {
-- { name = 'cmdline' }
-- })
-- })
end
--- Blink
local cmp = require("blink.cmp")
cmp.setup(opts)
end,
},
}
-- return {
-- {
-- 'hrsh7th/nvim-cmp',
-- dependencies = {
-- 'hrsh7th/cmp-nvim-lsp',
-- 'hrsh7th/cmp-buffer',
-- 'hrsh7th/cmp-path',
-- 'hrsh7th/cmp-cmdline',
-- 'onsails/lspkind.nvim',
-- { 'L3MON4D3/LuaSnip', build = "make install_jsregexp" },
-- 'saadparwaiz1/cmp_luasnip',
-- 'rafamadriz/friendly-snippets',
-- },
-- lazy = false,
-- priority = 100,
-- config = function()
-- vim.opt.completeopt = { "menu", "menuone" }
--
--
-- local lspkind = require('lspkind')
-- local cmp = require('cmp')
-- local ls = require("luasnip")
-- ls.setup({
-- history = true,
-- })
--
-- ls.filetype_extend("latex", { "tex" })
--
-- -- require("luasnip.loaders.from_vscode").lazy_load()
-- require("luasnip.loaders.from_lua").load({
-- -- paths = vim.api.nvim_get_runtime_file("lua/kamu/snippets/", true)[1]
-- paths = "~/.config/nvim/lua/kamu/snippets/",
-- })
-- -- require("luasnip.loaders").edit_snippet_files()
--
-- -- vim.keymap.set({ "i", "s" }, "<Tab>", function()
-- -- if ls.expand_or_jumpable() then
-- -- ls.expand_or_jump()
-- -- else
-- -- return "<Tab>"
-- -- end
-- -- end, { expr = true, silent = true })
-- --
-- -- vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
-- -- if ls.jumpable(-1) then
-- -- ls.jump(-1)
-- -- else
-- -- print("can't go further back")
-- -- end
-- -- end, { silent = true })
--
-- cmp.setup({
-- formatting = {
-- format = lspkind.cmp_format({
-- mode = 'symbol_text',
-- }),
-- },
-- ellipsis_char = '...',
-- show_labelDetails = true,
-- snippet = {
-- expand = function(args)
-- -- vim.snippet.expand(args.body)
-- require('luasnip').lsp_expand(args.body)
-- end,
-- },
-- maxwidth = {
-- menu = 50,
-- abbr = 50,
-- },
-- window = {
-- -- completion = cmp.config.window.bordered(),
-- -- documentation = cmp.config.window.bordered(),
-- },
-- mapping = cmp.mapping.preset.insert({
-- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- ['<C-Space>'] = cmp.mapping.complete(),
-- ['<C-e>'] = cmp.mapping.abort(),
-- -- ['<Tab>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- ['<Tab>'] = cmp.mapping(function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- vim.fn.feedkeys(T('<C-n>'), 'n')
-- elseif ls.expand_or_jumpable() then
-- ls.expand_or_jump()
-- elseif not check_backspace() then
-- cmp.mapping.complete()(core, fallback)
-- else
-- vim.cmd(':>')
-- vim.cmd(':startinsert')
-- end
-- end, { "i", "s" }),
-- ['<S-Tab>'] = cmp.mapping(function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- vim.fn.feedkeys(T('<C-p>'), 'n')
-- elseif ls.jumpable(-1) then
-- ls.jump(-1)
-- else
-- vim.cmd(':<')
-- vim.cmd(':startinsert')
-- end
-- end, { "i", "s" }),
-- }),
-- sources = cmp.config.sources({
-- { name = 'nvim_lsp' },
-- { name = 'luasnip' },
-- { name = 'path' },
-- { name = 'buffer' },
-- }),
-- })
--
-- -- Set configuration for specific filetype.
-- -- cmp.setup.filetype('gitcommit', {
-- -- sources = cmp.config.sources({
-- -- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
-- -- }, {
-- -- { name = 'buffer' },
-- -- })
-- -- })
--
-- -- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
-- -- cmp.setup.cmdline({ '/', '?' }, {
-- -- mapping = cmp.mapping.preset.cmdline(),
-- -- sources = {
-- -- { name = 'buffer' }
-- -- }
-- -- })
-- --
--
-- -- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
-- -- cmp.setup.cmdline(':', {
-- -- mapping = cmp.mapping.preset.cmdline(),
-- -- sources = cmp.config.sources({
-- -- { name = 'path' }
-- -- }, {
-- -- { name = 'cmdline' }
-- -- })
-- -- })
-- end
-- },
-- }

View File

@@ -4,18 +4,10 @@ return {
dependencies = {
"williamboman/mason.nvim", -- https://github.com/williamboman/mason.nvim
"williamboman/mason-lspconfig.nvim", -- https://github.com/williamboman/mason-lspconfig.nvim bridges the gab between lspconfig and mason
{
"folke/lazydev.nvim", -- https://github.com/folke/lazydev.nvim
ft = "lua",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
'saghen/blink.cmp',
},
config = function()
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local capabilities = require('blink.cmp').get_lsp_capabilities()
require('mason').setup()
require('mason-lspconfig').setup({

View File

@@ -0,0 +1,23 @@
return {
{
'stevearc/oil.nvim',
-- Optional dependencies
dependencies = { { "echasnovski/mini.icons", opts = {} } },
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
config = function()
---@module 'oil'
---@type oil.SetupOpts
local opts = {
columns = {
"icon",
"permissions",
-- "size",
-- "mtime"
},
}
require("oil").setup(opts)
vim.keymap.set("n", "<leader>-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
end
}
}

View File

@@ -0,0 +1,14 @@
return {
{
'syss-report-selector',
dev = true,
enabled = true,
dependencies = {
"nvim-telescope/telescope.nvim",
},
lazy = false,
config = function()
vim.keymap.set('n', "<leader>frf", require('syss-report-selector').directory_picker, {})
end
}
}

View File

@@ -22,7 +22,7 @@ return {
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files)
vim.keymap.set('n', '<leader>fn', function() builtin.find_files { cwd = vim.fn.stdpath("config") } end)
vim.keymap.set('n', '<leader>fr', function()
vim.keymap.set('n', '<leader>frg', function()
builtin.live_grep {
cwd = "~/reports",
file_ignore_patterns = { "/Makefile$", "%.png$", "%.PNG$" }

View File

@@ -1,50 +0,0 @@
return {
'nvim-tree/nvim-tree.lua',
dependencies = {
{ 'nvim-tree/nvim-web-devicons' }
},
opts = {
view = { width = 40 },
},
config = function()
local function my_on_attach(bufnr)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set("n", "<leader>ee", ":NvimTreeToggle<CR>") -- toggle file explorer
vim.keymap.set("n", "<leader>er", ":NvimTreeFocus<CR>") -- toggle focus to file explorer
vim.keymap.set("n", "<leader>ef", ":NvimTreeFindFile<CR>") -- find file in file explorer
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', '<leader><Enter>', api.tree.change_root_to_node, opts('CD'))
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
end
-- pass to setup along with your other options
require("nvim-tree").setup {
---
on_attach = my_on_attach,
---
}
end
}
-- Currently this will not load the keymaps if the plugin is not loaded. You have to manually open the tree to load the keymaps.
-- I am also thinking about switching to neo-tree:
-- {
-- "nvim-neo-tree/neo-tree.nvim",
-- branch = "v3.x",
-- dependencies = {
-- "nvim-lua/plenary.nvim",
-- "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
-- "MunifTanjim/nui.nvim",
-- -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
-- }
-- }

View File

@@ -1,10 +1,10 @@
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function ()
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = {
ensure_installed = {
"c",
"cpp",
"bash",
@@ -27,8 +27,8 @@ return {
sync_install = false,
highlight = { enable = true },
auto_install = true, -- automatically install syntax support when entering new file type buffer
indent = { enable = true },
indent = { enable = true },
ignore_install = {},
})
end,
}

Submodule .config/nvim/lua/kamu/snippets added at 6c6d7238f4

View File

@@ -1,31 +0,0 @@
-- require("luasnip.session.snippet_collection").clear_snippets("tex")
local ls = require("luasnip")
local s = ls.snippet
local i = ls.insert_node
local sn = ls.snippet_node
local t = ls.text_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local fmt = require("luasnip.extras.fmt").fmt
local snippets = {
-- s("todo", fmt("\\sytodo[{}]{{ {} }}{}", { c(1, { t("todo"), t("techqa") }), i(2, "techqa"), i(0) })),
s("todo",
fmt("\\sytodo[{}]{{{}}}{}",
{
i(1, "techqa"),
i(2),
i(0)
}
)
)
}
local autosnippets = {}
ls.add_snippets("tex", snippets)
return snippets, autosnippets

View File

@@ -0,0 +1,107 @@
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local utils = require("telescope.utils")
local entry_display = require "telescope.pickers.entry_display"
local M = {}
M.setup = function(opts)
opts = opts or {}
-- TODO: get report directory from settings or maybe reportctl ini file?
M.report_dir = opts.report_dir or "~/reports"
-- do nothing
end
-- Function to get directories in the current directory
M.get_reports = function()
local report_dir = M.report_dir or "~/reports"
-- insecure
local handle = io.popen("find " .. report_dir .. " -maxdepth 2 -mindepth 2 -type d")
if not handle then return {} end
local result = handle:read("*a")
handle:close()
return vim.split(result, "\n", { trimempty = true })
end
local debug = function(msg, title)
msg = msg or ""
title = title or ""
Snacks.notifier.notify(msg, "debug", { style = "compact", timeout = 10000, title = title })
end
local info = function(msg, title)
msg = msg or ""
title = title or ""
Snacks.notifier.notify(msg, "info", { style = "compact", timeout = 10000, title = title })
end
M.directory_picker = function(opts)
opts = opts or {}
local dirs = M.get_reports()
local displayer = entry_display.create({
separator = "",
items = {
{ width = 25 },
{ remaining = true },
}
})
local make_display = function(e)
-- debug(vim.inspect(e.value))
local parts = vim.split(e.value, '/', { trimempty = true, plain = true })
local kunde = parts[#parts - 1]
local report = parts[#parts]
local display = kunde .. " " .. report
local kundeStart = 0
local kundeEnd = #kunde
local reportStart = kundeEnd + 1
local reportEnd = reportStart + #report
return displayer {
{ kunde, "TelescopeResultsComment" },
{ report, "TelescopeResultsIdentifier" },
}
end
local reportFinder = finders.new_table({
results = dirs,
entry_maker = function(entry)
return {
value = entry,
ordinal = entry,
display = make_display,
}
end
})
pickers.new(opts, {
prompt_title = "Select report",
finder = reportFinder,
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
local function set_cwd()
local selection = action_state.get_selected_entry()
if selection then
local selected_dir = selection.value
vim.cmd("cd " .. selected_dir)
info(selected_dir, "Switched report")
end
actions.close(prompt_bufnr)
end
map("i", "<CR>", set_cwd)
map("n", "<CR>", set_cwd)
return true
end,
}):find()
end
return M

0
.gitmodules vendored Normal file
View File