diff --git a/.config/lvim/after/ftplugin/norg.lua b/.config/lvim/after/ftplugin/norg.lua new file mode 100644 index 0000000..dab0800 --- /dev/null +++ b/.config/lvim/after/ftplugin/norg.lua @@ -0,0 +1,4 @@ +vim.cmd([[ +inoremap o- [ ] +nnoremap o- [ ] +]]) diff --git a/.config/lvim/config.lua b/.config/lvim/config.lua new file mode 100644 index 0000000..d7da03e --- /dev/null +++ b/.config/lvim/config.lua @@ -0,0 +1,94 @@ +-- Options +lvim.colorscheme = "tokyonight" +lvim.log.level = "warn" +lvim.format_on_save = true +lvim.builtin.alpha.mode = "startify" +lvim.builtin.nvimtree.show_icons.git = 1 +lvim.builtin.lualine.options.globalstatus = true + +local o = vim.opt +o.timeoutlen = 300 +o.shell = "/bin/sh" + +table.insert(lvim.builtin.cmp.sources, {name = "cmdline"} ) +table.insert(lvim.builtin.cmp.sources, {name = "cmp_git"} ) +table.insert(lvim.builtin.cmp.sources, {name = "digraphs"} ) +table.insert(lvim.builtin.cmp.sources, {name = "spell", keyword_length = 3} ) +table.insert(lvim.builtin.cmp.sources, {name = "dictionary", keyword_length = 3} ) +table.insert(lvim.builtin.cmp.sources, {name = "rg", keyword_length = 3} ) + +-- Keymappings +lvim.leader = "space" + +local delete = function () end +local cmp_status_ok, cmp = pcall (require, 'cmp') +if cmp_status_ok then + lvim.builtin.cmp.formatting.kind_icons.Method = "m " + lvim.builtin.cmp.formatting.kind_icons.Module = " " + lvim.builtin.cmp.formatting.kind_icons.Variable = " " + lvim.builtin.cmp.formatting.kind_icons.Constant = " " + lvim.builtin.cmp.formatting.kind_icons.Interface = " " + lvim.builtin.cmp.formatting.kind_icons.Field = "ﰠ " + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = cmp.mapping.confirm { select = true} + lvim.builtin.cmp.mapping[""] = delete() + lvim.builtin.cmp.mapping[""] = cmp.mapping.scroll_docs(-4) +end +lvim.keys.normal_mode[""] = ":w" + +lvim.builtin.which_key.mappings["P"] = { "Telescope projects", "Projects" } +lvim.builtin.which_key.mappings["t"] = { + name = "+Trouble", + r = { "Trouble lsp_references", "References" }, + f = { "Trouble lsp_definitions", "Definitions" }, + d = { "Trouble lsp_document_diagnostics", "Diagnostics" }, + q = { "Trouble quickfix", "QuickFix" }, + l = { "Trouble loclist", "LocationList" }, + w = { "Trouble lsp_workspace_diagnostics", "Diagnostics" }, +} + +lvim.builtin.which_key.mappings["n"] = { + name = "+Neorg", + s = { ":NeorgStart silent=true", "Start"}, + t = { ":Neorg gtd capture", "New Task"}, + v = { ":Neorg gtd views", "View Tasks"}, + e = { ":Neorg gtd edit", "Edit Tasks"}, + w = { ":Neorg news all", "Neorg News"}, + d = { + name = "+Journal", + t = { ":Neorg journal today", "Today" }, + y = { ":Neorg journal yesterday", "Yesterday" }, + n = { ":Neorg journal tomorrow", "Tomorrow" }, + c = { ":Neorg journal custom", "Custom" }, + }, +} + +-- Plugins +local req = function (module) + require(module) +end +lvim.builtin.notify.active = true +lvim.builtin.terminal.active = true +lvim.builtin.dap.active = true + +lvim.plugins = { + { "folke/tokyonight.nvim", + config = function() + vim.cmd[[colorscheme tokyonight]] + end, }, + { "petertriho/cmp-git" }, + { "uga-rosa/cmp-dictionary" }, + { "dmitmel/cmp-digraphs"}, + { "lukas-reineke/cmp-rg" }, + { "nvim-neorg/neorg", config = req "conf.neorg", }, + { "folke/trouble.nvim", cmd = "TroubleToggle", }, +} + +require "conf.luasnip" +require "conf.dap" +require "conf.dictionary" diff --git a/.config/lvim/lua/conf/dap.lua b/.config/lvim/lua/conf/dap.lua new file mode 100644 index 0000000..cc17155 --- /dev/null +++ b/.config/lvim/lua/conf/dap.lua @@ -0,0 +1,51 @@ +local status_ok, dap = pcall(require, 'dap') +if not status_ok then + return +end + +dap.adapters.lldb = { + type = 'executable', + command = '/usr/bin/lldb-vscode', -- adjust as needed + name = "lldb" +} + +dap.configurations.cpp = { + { + name = "Launch", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + + -- 💀 + -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: + -- + -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope + -- + -- Otherwise you might get the following error: + -- + -- Error on launch: Failed to attach to the target process + -- + -- But you should be aware of the implications: + -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html + + runInTerminal = false, + + -- 💀 + -- If you use `runInTerminal = true` and resize the terminal window, + -- lldb-vscode will receive a `SIGWINCH` signal which can cause problems + -- To avoid that uncomment the following option + -- See https://github.com/mfussenegger/nvim-dap/issues/236#issuecomment-1066306073 + postRunCommands = {'process handle -p true -s false -n false SIGWINCH'} + }, +} + + +-- If you want to use this for rust and c, add something like this: + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp diff --git a/.config/lvim/lua/conf/luasnip.lua b/.config/lvim/lua/conf/luasnip.lua new file mode 100644 index 0000000..7ee9fee --- /dev/null +++ b/.config/lvim/lua/conf/luasnip.lua @@ -0,0 +1,89 @@ +local status_ok, ls = pcall(require, "luasnip") +if not status_ok then + return +end + +local types = require "luasnip.util.types" + +ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + enable_autosnippets = true, + ext_opts = { + [types.choiceNode] = { + active = { + virt_text = {{"●", "Error"}} + } + }, + [types.insertNode] = { + active = { + virt_text = {{"|", "Ok"}} + } + } + }, +} + +local snippet = ls.s +local i = ls.insert_node +local t = ls.text_node +-- local types = require "luasnip.util.types" +-- local f = ls.function_node +-- local c = ls.choice_node +-- local rep = require('luasnip.extras').rep +-- local fmt = require('luasnip.extras.fmt').fmt + +local opts = { silent = true } +local map = vim.keymap.set + +map({"i", "s"}, "", function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end +end, opts ) +map({"i", "s"}, "", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end, opts ) +map({"i",}, "", function() + if ls.choice_active() then + ls.change_choice(1) + end +end, opts ) +map("n", "s", "source ~/.config/lvim/luasnip.lua" , opts) + +local shortcut = function(val) + if type(val) == "string" then + return { t { val }, i(0) } + end + + if type(val) == "table" then + for k, v in ipairs(val) do + if type(v) == "string" then + val[k] = t { v } + end + end + end + + return val +end + +local make = function(tbl) + local result = {} + for k, v in pairs(tbl) do + table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v)))) + end + + return result +end + +local snippets = {} + +snippets.all = {} + +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("snips/*.lua", true)) do + local ft = vim.fn.fnamemodify(ft_path, ":t:r") + snippets[ft] = make(loadfile(ft_path)()) +end + +ls.snippets = snippets diff --git a/.config/lvim/lua/conf/neorg.lua b/.config/lvim/lua/conf/neorg.lua new file mode 100644 index 0000000..f9bd1d9 --- /dev/null +++ b/.config/lvim/lua/conf/neorg.lua @@ -0,0 +1,34 @@ +local status_ok, neorg = pcall(require, 'neorg') +if not status_ok then + vim.notify 'Neorg did not load' + return +end + +neorg.setup { + load = { + ["core.defaults"] = {}, + ["core.norg.journal"] = { + config = { + workspace = "notes" + } + }, + ["core.norg.dirman"] = { + config = { + workspaces = { + notes = "~/Documents/notes", + }, + autochdir = true, + index = "index.norg", + } + }, + ["core.gtd.base"] = { + config = { + workspace = "notes", + } + }, + ["core.gtd.ui"] = {}, + ["core.norg.concealer"] = {}, + -- ["core.norg.completion"] = { config = { 'nvim-cmp'}}, + -- ["core.integrations.nvim-cmp"] = {}, + } +}