diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 72c5c82..3737153 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -176,7 +176,7 @@ map me mkfile_and_edit map gh cd map gd cd ~/Downloads map gr cd ~/repos -map gz cd ~/work +map gz cd ~/notes map gn cd ~/nextcloud map gH cd ~/nextcloud/university/Honours map gcc cd ~/.config @@ -187,6 +187,7 @@ map gcxm cd ~/.xmonad map gcs cd ~/.config/shell map gcz cd ~/.config/zsh map gcx1 cd ~/.config/x11 +map gw cd ~/work map A rename # at the very end map c push A # new rename diff --git a/.config/nvim/lua/chris/cmp.lua b/.config/nvim/lua/chris/cmp.lua index a364f2e..941c724 100644 --- a/.config/nvim/lua/chris/cmp.lua +++ b/.config/nvim/lua/chris/cmp.lua @@ -1,200 +1,200 @@ local cmp_status_ok, cmp = pcall(require, "cmp") if not cmp_status_ok then - return + return end local snip_status_ok, luasnip = pcall(require, "luasnip") if not snip_status_ok then - return + return end local buffer_fts = { - "markdown", - "toml", - "yaml", - "json", + "markdown", + "toml", + "yaml", + "json", } local function contains(t, value) - for _, v in pairs(t) do - if v == value then - return true - end - end - return false + for _, v in pairs(t) do + if v == value then + return true + end + end + return false end -local compare = require "cmp.config.compare" +local compare = require("cmp.config.compare") require("luasnip/loaders/from_vscode").lazy_load() local check_backspace = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end -local icons = require "chris.icons" +local icons = require("chris.icons") local kind_icons = icons.kind -- I don't have most of the following but they can serve as future examples vim.g.cmp_active = true -cmp.setup { - enabled = function() - local buftype = vim.api.nvim_buf_get_option(0, "buftype") - if buftype == "prompt" then - return false - end - return vim.g.cmp_active - end, - preselect = cmp.PreselectMode.None, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - -- [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - -- Accept currently selected item. If none selected, `select` first item. - -- Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm { select = false }, - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.jumpable(1) then - luasnip.jump(1) - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif luasnip.expandable() then - luasnip.expand() - elseif check_backspace() then - -- cmp.complete() - fallback() - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { - "i", - "s", - }), - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = kind_icons[vim_item.kind] +cmp.setup({ + enabled = function() + local buftype = vim.api.nvim_buf_get_option(0, "buftype") + if buftype == "prompt" then + return false + end + return vim.g.cmp_active + end, + preselect = cmp.PreselectMode.None, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + -- [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ select = false }), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.jumpable(1) then + luasnip.jump(1) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif luasnip.expandable() then + luasnip.expand() + elseif check_backspace() then + -- cmp.complete() + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }), + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = kind_icons[vim_item.kind] - if entry.source.name == "lab.quick_data" then - vim_item.kind = icons.misc.CircuitBoard - vim_item.kind_hl_group = "CmpItemKindConstant" - end + if entry.source.name == "lab.quick_data" then + vim_item.kind = icons.misc.CircuitBoard + vim_item.kind_hl_group = "CmpItemKindConstant" + end - -- NOTE: order matters - vim_item.menu = ({ - nvim_lsp = "[LSP]", - nvim_lua = "[LUA]", - luasnip = "[SNP]", - buffer = "[BUF]", - path = "[PTH]", - })[entry.source.name] - return vim_item - end, - }, - sources = { - { - name = "nvim_lsp", - filter = function(entry, ctx) - local kind = require("cmp.types.lsp").CompletionItemKind[entry:get_kind()] - if kind == "Snippet" and ctx.prev_context.filetype == "java" then - return true - end + -- NOTE: order matters + vim_item.menu = ({ + nvim_lsp = "[LSP]", + nvim_lua = "[LUA]", + luasnip = "[SNP]", + buffer = "[BUF]", + path = "[PTH]", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { + name = "nvim_lsp", + filter = function(entry, ctx) + local kind = require("cmp.types.lsp").CompletionItemKind[entry:get_kind()] + if kind == "Snippet" and ctx.prev_context.filetype == "java" then + return true + end - if kind == "Text" then - return true - end - end, - group_index = 2, - }, - { name = "nvim_lua", group_index = 2 }, - { name = "luasnip", group_index = 2 }, - { - name = "buffer", - group_index = 2, - filter = function(entry, ctx) - if not contains(buffer_fts, ctx.prev_context.filetype) then - return true - end - end, - }, - { name = "path", group_index = 2 }, - { name = "lab.quick_data", keyword_length = 4, group_index = 2 }, - }, - sorting = { - priority_weight = 2, - comparators = { - compare.offset, - compare.exact, - -- compare.scopes, - compare.score, - compare.recently_used, - compare.locality, - -- compare.kind, - compare.sort_text, - compare.length, - compare.order, - }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - window = { - documentation = false, - completion = { - border = "rounded", - winhighlight = "NormalFloat:Pmenu,NormalFloat:Pmenu,CursorLine:PmenuSel,Search:None", - }, - }, - experimental = { - ghost_text = true, - }, -} + if kind == "Text" then + return true + end + end, + group_index = 2, + }, + { name = "nvim_lua", group_index = 2 }, + { name = "luasnip", group_index = 2 }, + { + name = "buffer", + group_index = 2, + filter = function(entry, ctx) + if not contains(buffer_fts, ctx.prev_context.filetype) then + return true + end + end, + }, + { name = "path", group_index = 2 }, + { name = "lab.quick_data", keyword_length = 4, group_index = 2 }, + }, + sorting = { + priority_weight = 2, + comparators = { + compare.offset, + compare.exact, + -- compare.scopes, + compare.score, + compare.recently_used, + compare.locality, + -- compare.kind, + compare.sort_text, + compare.length, + compare.order, + }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + documentation = false, + completion = { + border = "rounded", + winhighlight = "NormalFloat:Pmenu,NormalFloat:Pmenu,CursorLine:PmenuSel,Search:None", + }, + }, + experimental = { + ghost_text = true, + }, +}) diff --git a/.config/nvim/lua/lazyvim/init.lua b/.config/nvim/lua/lazyvim/init.lua index 2f3e3ff..52eac2c 100644 --- a/.config/nvim/lua/lazyvim/init.lua +++ b/.config/nvim/lua/lazyvim/init.lua @@ -13,11 +13,13 @@ end vim.opt.rtp:prepend(vim.env.LAZY or lazypath) -require("lazy").setup({ - spec = "lazyvim.plugins", - defaults = { lazy = true, version = "*" }, - checker = { enabled = true }, -}) +if not vim.g.vscode then + require("lazy").setup({ + spec = "lazyvim.plugins", + defaults = { lazy = true, version = "*" }, + checker = { enabled = true }, + }) +end -- map leader and register keymap for Lazy. vim.g.mapleader = " " diff --git a/.config/nvim/lua/lazyvim/plugins/whichkey.lua b/.config/nvim/lua/lazyvim/plugins/whichkey.lua index f8fcd52..1dc18af 100644 --- a/.config/nvim/lua/lazyvim/plugins/whichkey.lua +++ b/.config/nvim/lua/lazyvim/plugins/whichkey.lua @@ -70,11 +70,18 @@ return { t = { name = "+todo" }, N = { name = "+noice" }, - n = { "NvimTreeToggle", "Explorer" }, + e = { "NvimTreeToggle", "Explorer" }, z = { "ZenMode", "Zen" }, u = { "UndotreeToggle", "Undo Tree" }, ["'"] = { "close", "Close split" }, + n = { + name = "+neorg", + n = { "Neorg", "Open Neorg" }, + j = { "Neorg journal", "Open Neorg Journal" }, + w = { "Neorg workspace", "Open Neorg Workspace" }, + }, + f = { name = "+file", n = { "enew", "New File" }, diff --git a/.config/nvim/lua/lazyvim/teletest.lua b/.config/nvim/lua/lazyvim/teletest.lua new file mode 100644 index 0000000..937625c --- /dev/null +++ b/.config/nvim/lua/lazyvim/teletest.lua @@ -0,0 +1,38 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") +local conf = require("telescope.config").values + +local prompt = function(opts, prompt, options, callback) + opts = opts or {} + pickers + .new(opts, { + prompt_title = prompt, + finder = finders.new_table({ + results = options, + entry_marker = function(entry) + return { + value = entry, + display = entry[1], + ordinal = entry[1], + } + end, + }), + sorter = conf.generic_sorter(opts), + attach_mappings = function(promnt_bufnr, map) + actions.select_default:replace(function() + actions.close(promnt_bufnr) + local selection = action_state.get_selected_entry() + vim.notify(selection[1]) + end) + return true + end, + }) + :find() +end + +prompt(require("telescope.themes").get_dropdown({}), "test", { + { "one", "1" }, + { "two", "2" }, +}, nil)