From 68cdfcc3a38105a962ea79df8a3a01196ac0d6c2 Mon Sep 17 00:00:00 2001 From: Adi De Masi Date: Fri, 19 Dec 2025 12:58:12 +0100 Subject: [PATCH] Customizations based on previous config probably still bloated --- init.lua | 87 +++----- lua/custom/plugins/bufferline.lua | 1 + lua/custom/plugins/conform.lua | 93 ++++++++ lua/custom/plugins/copilot.lua | 25 +++ lua/custom/plugins/lazyvim.lua | 8 + lua/custom/plugins/lsp.lua | 229 ++++++++++++++++++++ lua/custom/plugins/markdown-preview.lua | 17 ++ lua/custom/plugins/nvim-surround.lua | 10 + lua/custom/plugins/nvim-tmux-navigation.lua | 19 ++ lua/custom/plugins/nvim-tree.lua | 13 ++ lua/custom/plugins/obsidian.lua | 72 ++++++ lua/custom/plugins/plenary.lua | 3 + lua/custom/plugins/render-markdown.lua | 9 + lua/custom/plugins/tasko.lua | 13 ++ lua/custom/plugins/trouble.lua | 37 ++++ lua/custom/plugins/typescript-tools.lua | 5 + lua/keymaps.lua | 118 ++++++++++ 17 files changed, 703 insertions(+), 56 deletions(-) create mode 100644 lua/custom/plugins/bufferline.lua create mode 100644 lua/custom/plugins/conform.lua create mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/lazyvim.lua create mode 100644 lua/custom/plugins/lsp.lua create mode 100644 lua/custom/plugins/markdown-preview.lua create mode 100644 lua/custom/plugins/nvim-surround.lua create mode 100644 lua/custom/plugins/nvim-tmux-navigation.lua create mode 100644 lua/custom/plugins/nvim-tree.lua create mode 100644 lua/custom/plugins/obsidian.lua create mode 100644 lua/custom/plugins/plenary.lua create mode 100644 lua/custom/plugins/render-markdown.lua create mode 100644 lua/custom/plugins/tasko.lua create mode 100644 lua/custom/plugins/trouble.lua create mode 100644 lua/custom/plugins/typescript-tools.lua create mode 100644 lua/keymaps.lua diff --git a/init.lua b/init.lua index b98ffc61..ff4a01e1 100644 --- a/init.lua +++ b/init.lua @@ -83,15 +83,22 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] +-- +-- +-- NvimTree +-- disable netrw at the very start of your init.lua +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' +vim.g.mapleader = ',' +vim.g.maplocalleader = ',' +vim.g.vscode_snippets_path = '~/.config/lvim/snippets/my-snippets' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.o` @@ -100,6 +107,9 @@ vim.g.have_nerd_font = false -- Make line numbers default vim.o.number = true + +require 'keymaps' + -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! -- vim.o.relativenumber = true @@ -344,7 +354,7 @@ require('lazy').setup({ -- Document existing key chains spec = { - { 's', group = '[S]earch' }, + { 'f', group = '[F]ind' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, @@ -426,15 +436,15 @@ require('lazy').setup({ -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) + vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' }) + vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[F]ind [F]iles' }) + vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' }) + vim.keymap.set('n', 'fw', builtin.grep_string, { desc = '[F]ind current [W]ord' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[F]ind by [G]rep' }) + vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' }) + vim.keymap.set('n', 'fr', builtin.resume, { desc = '[F]ind [R]esume' }) + vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme @@ -448,17 +458,17 @@ require('lazy').setup({ -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() + vim.keymap.set('n', 'f/', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } - end, { desc = '[S]earch [/] in Open Files' }) + end, { desc = '[F]ind [/] in Open Files' }) -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() + vim.keymap.set('n', 'fn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) + end, { desc = '[F]ind [N]eovim files' }) end, }, @@ -535,43 +545,8 @@ require('lazy').setup({ vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - - -- Find references for the word under your cursor. - map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') - + -- Check out lua/custom/plugins/lsp.lua for more lsp related keymaps + -- -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) ---@param client vim.lsp.Client ---@param method vim.lsp.protocol.Method @@ -742,7 +717,7 @@ require('lazy').setup({ cmd = { 'ConformInfo' }, keys = { { - 'f', + 'F', function() require('conform').format { async = true, lsp_format = 'fallback' } end, @@ -984,7 +959,7 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua new file mode 100644 index 00000000..d3f2faa6 --- /dev/null +++ b/lua/custom/plugins/bufferline.lua @@ -0,0 +1 @@ +return { 'akinsho/bufferline.nvim', version = '*', dependencies = 'nvim-tree/nvim-web-devicons' } diff --git a/lua/custom/plugins/conform.lua b/lua/custom/plugins/conform.lua new file mode 100644 index 00000000..3b7fa781 --- /dev/null +++ b/lua/custom/plugins/conform.lua @@ -0,0 +1,93 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + -- Customize or remove this keymap to your liking + 'lf', + function() + require('conform').format { async = false } + end, + mode = 'n', + desc = 'Format buffer', + }, + }, + -- This will provide type hinting with LuaLS + ---@module "conform" + ---@type conform.setupOpts + opts = { + -- Define your formatters + formatters_by_ft = { + lua = { 'stylua' }, + python = { 'isort', 'black' }, + javascript = { 'eslint_d' }, + typescript = { 'eslint_d' }, + html = { 'eslint_d' }, + css = { 'eslint_d' }, + }, + -- Set default options + default_format_opts = { + lsp_format = 'fallback', + }, + -- Set up format-on-save + format_on_save = function(bufnr) + -- Disable format_on_save for TypeScript to prevent auto-indent conflicts + local filetype = vim.bo[bufnr].filetype + if filetype == 'typescript' or filetype == 'typescriptreact' or filetype == 'ts' or filetype == 'tsx' then + return false + end + return { timeout_ms = 500 } + end, + -- Customize formatters + formatters = { + shfmt = { + prepend_args = { '-i', '2' }, + }, + }, + eslint_d = { + args = { '--fix', '--stdin', '--stdin-filename', '$FILENAME' }, + cwd = function(bufnr) + local bufname = vim.api.nvim_buf_get_name(bufnr) + return vim.fs.dirname(bufname) + end, + }, + }, + init = function() + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" + + -- Set TypeScript indentation to 2 spaces and disable ALL auto-formatting/indenting + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'typescript', 'typescriptreact', 'ts', 'tsx' }, + callback = function() + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + -- Disable ALL auto-indent/format options + vim.opt_local.autoindent = false + vim.opt_local.smartindent = false + vim.opt_local.cindent = false + vim.opt_local.indentexpr = '' + vim.opt_local.equalprg = '' + vim.opt_local.formatprg = '' + vim.opt_local.formatexpr = '' + -- Disable vim-sleuth for TypeScript files + vim.b.sleuth_automatic = 0 + end, + }) + + -- Prevent ANY auto-indent/format before write for TypeScript files + vim.api.nvim_create_autocmd('BufWritePre', { + pattern = { '*.ts', '*.tsx' }, + callback = function() + -- Completely disable all formatting/indenting right before save + vim.opt_local.indentexpr = '' + vim.opt_local.equalprg = '' + vim.opt_local.formatprg = '' + vim.opt_local.formatexpr = '' + vim.opt_local.autoindent = false + vim.opt_local.smartindent = false + vim.opt_local.cindent = false + end, + }) + end, +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..8a70374d --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,25 @@ +return { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + event = 'InsertEnter', + -- Load before nvim-cmp to ensure copilot is ready + priority = 100, + config = function() + require('copilot').setup { + suggestion = { + enabled = true, + auto_trigger = true, -- Need to trigger to get suggestions for copilot-cmp + debounce = 75, + keymap = { + accept = false, -- Disable accept keymap, use copilot-cmp instead + accept_word = false, + accept_line = false, + next = '', + prev = '', + dismiss = '', + }, + }, + panel = { enabled = true }, + } + end, +} diff --git a/lua/custom/plugins/lazyvim.lua b/lua/custom/plugins/lazyvim.lua new file mode 100644 index 00000000..07995784 --- /dev/null +++ b/lua/custom/plugins/lazyvim.lua @@ -0,0 +1,8 @@ +return { + "kdheepak/lazygit.nvim", + cmd = "LazyGit", + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, +} diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua new file mode 100644 index 00000000..cf3e835a --- /dev/null +++ b/lua/custom/plugins/lsp.lua @@ -0,0 +1,229 @@ +return { + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + -- 'williamboman/mason.nvim', + -- 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + { 'j-hui/fidget.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, + config = function() + -- Mappings. + -- See `:help vim.diagnostic.*` for documentation on any of the below functions + local opts = { silent = true } + + function optsWithDesc(desc) + return { desc = desc } + end + + -- the following diagnostic commands don't work :( + -- vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) + -- vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + --- end of not working + + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, optsWithDesc 'previous diagnostics') + vim.keymap.set('n', ']d', vim.diagnostic.goto_next, optsWithDesc 'next diagnostics') + + vim.api.nvim_create_autocmd('FileType', { + pattern = 'sh', + callback = function() + vim.lsp.start { + name = 'bash-language-server', + cmd = { 'bash-language-server', 'start' }, + } + end, + }) + + -- Use an on_attach function to only map the following keys + -- after the language server attaches to the current buffer + local on_attach = function(client, bufnr) + function bufoptsWithDesc(desc) + return { silent = true, buffer = bufnr, desc = desc } + end + + local function telescope_lsp(picker, fallback, picker_opts) + return function() + local ok, builtin = pcall(require, 'telescope.builtin') + if ok and type(builtin[picker]) == 'function' then + return builtin[picker](picker_opts or {}) + end + return fallback() + end + end + + vim.keymap.set( + 'n', + 'ls', + telescope_lsp('lsp_document_symbols', vim.lsp.buf.document_symbol), + bufoptsWithDesc 'Open symbol picker' + ) + vim.keymap.set( + 'n', + 'lS', + telescope_lsp('lsp_dynamic_workspace_symbols', vim.lsp.buf.workspace_symbol), + bufoptsWithDesc 'Open symbol picker (workspace)' + ) + vim.keymap.set( + 'n', + 'dd', + telescope_lsp('diagnostics', vim.diagnostic.setloclist), + bufoptsWithDesc 'Open diagnostics picker' + ) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufoptsWithDesc 'LSP Hover') + -- Neovim (0.11+) sets default LSP keymaps from `vim/_defaults.lua` on `LspAttach`. + -- Those can overwrite mappings set inside `on_attach`, so we schedule our preferred + -- mappings to run after the defaults. + vim.schedule(function() + -- Prefer Telescope UI for "jump-to/list" LSP requests when available; + -- fall back to built-in LSP functions otherwise. + -- + -- NOTE: Telescope doesn't provide `lsp_declarations`, so `gD` always falls back. + vim.keymap.set( + 'n', + 'gd', + telescope_lsp('lsp_definitions', vim.lsp.buf.definition), + bufoptsWithDesc 'Definition (telescope)' + ) + vim.keymap.set( + 'n', + 'gr', + telescope_lsp('lsp_references', vim.lsp.buf.references), + bufoptsWithDesc 'References (telescope)' + ) + vim.keymap.set( + 'n', + 'gi', + telescope_lsp('lsp_implementations', vim.lsp.buf.implementation), + bufoptsWithDesc 'Implementation (telescope)' + ) + vim.keymap.set( + 'n', + 'gt', + telescope_lsp('lsp_type_definitions', vim.lsp.buf.type_definition), + bufoptsWithDesc 'Type definition (telescope)' + ) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufoptsWithDesc 'Declaration') + end) + -- TODO: C-k is already used for going to the top split figure out a different keymap + -- vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufoptsWithDesc("Signature help")) + -- vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufoptsWithDesc("")) + -- vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufoptsWithDesc()) + -- vim.keymap.set('n', 'wl', function() + -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + -- end, bufoptsWithDesc()) + vim.keymap.set('n', 'lr', function() + -- when rename opens the prompt, this autocommand will trigger + -- it will "press" CTRL-F to enter the command-line window `:h cmdwin` + -- in this window I can use normal mode keybindings + local cmdId + cmdId = vim.api.nvim_create_autocmd({ 'CmdlineEnter' }, { + callback = function() + local key = vim.api.nvim_replace_termcodes('', true, false, true) + vim.api.nvim_feedkeys(key, 'c', false) + vim.api.nvim_feedkeys('0', 'n', false) + -- autocmd was triggered and so we can remove the ID and return true to delete the autocmd + cmdId = nil + return true + end, + }) + vim.lsp.buf.rename() + -- if LPS couldn't trigger rename on the symbol, clear the autocmd + vim.defer_fn(function() + -- the cmdId is not nil only if the LSP failed to rename + vim.api.nvim_del_autocmd(cmdId) + if cmdId then + end + end, 500) + end, bufoptsWithDesc 'Rename symbol') + vim.keymap.set('n', 'lw', function() + vim.diagnostic.setloclist() + end, { desc = 'Diagnostic setloclist' }) + vim.keymap.set('n', 'la', vim.lsp.buf.code_action, bufoptsWithDesc 'Run code action') + -- vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufoptsWithDesc("Format using LSP")) + end + + -- Prefer blink.cmp capabilities if available (kickstart config uses blink.cmp), + -- otherwise fall back to vanilla LSP capabilities. + local capabilities = vim.lsp.protocol.make_client_capabilities() + local ok_blink, blink = pcall(require, 'blink.cmp') + if ok_blink and type(blink.get_lsp_capabilities) == 'function' then + capabilities = blink.get_lsp_capabilities(capabilities) + end + local lspconfig = vim.lsp.config + + lspconfig['gopls'] = { + capabilities = capabilities, + on_attach = on_attach, + } + vim.lsp.enable 'gopls' + + lspconfig['ts_ls'] = { + capabilities = capabilities, + on_attach = on_attach, + } + vim.lsp.enable 'ts_ls' + + lspconfig['sqlls'] = { + capabilities = capabilities, + on_attach = on_attach, + } + vim.lsp.enable 'sqlls' + + lspconfig['tailwindcss-language-server'] = { + capabilities = capabilities, + on_attach = on_attach, + filetypes = { 'html', 'css', 'scss', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'eruby' }, + } + vim.lsp.enable 'tailwindcss-language-server' + + lspconfig['ruby_lsp'] = { + capabilities = capabilities, + on_attach = on_attach, + mason = false, + cmd = { vim.fn.expand '~/.local/share/mise/installs/ruby/3.4.1/bin/ruby-lsp' }, + } + vim.lsp.enable 'ruby_lsp' + + lspconfig['lua_ls'] = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = { 'vim' }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + checkThirdParty = false, + }, + }, + }, + } + vim.lsp.enable 'lua_ls' + + lspconfig.marksman = {} + if vim.fn.executable 'solargraph' == 1 then + lspconfig['solargraph'] = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + flags = { + debounce_text_changes = 150, + }, + }, + } + end + end, +} diff --git a/lua/custom/plugins/markdown-preview.lua b/lua/custom/plugins/markdown-preview.lua new file mode 100644 index 00000000..a16a810a --- /dev/null +++ b/lua/custom/plugins/markdown-preview.lua @@ -0,0 +1,17 @@ +-- return { +-- 'iamcco/markdown-preview.nvim', +-- cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, +-- ft = { 'markdown' }, +-- build = function() +-- vim.fn['mkdp#util#install']() +-- end, +-- } +return { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, +} diff --git a/lua/custom/plugins/nvim-surround.lua b/lua/custom/plugins/nvim-surround.lua new file mode 100644 index 00000000..252d8414 --- /dev/null +++ b/lua/custom/plugins/nvim-surround.lua @@ -0,0 +1,10 @@ +return { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup { + -- Configuration here, or leave empty to use defaults + } + end, +} diff --git a/lua/custom/plugins/nvim-tmux-navigation.lua b/lua/custom/plugins/nvim-tmux-navigation.lua new file mode 100644 index 00000000..1a996eb2 --- /dev/null +++ b/lua/custom/plugins/nvim-tmux-navigation.lua @@ -0,0 +1,19 @@ +local plugins = { + "alexghergh/nvim-tmux-navigation", + lazy = false, + config = function() + require("nvim-tmux-navigation").setup { + disable_when_zoomed = true, -- defaults to false + keybindings = { + left = "", + down = "", + up = "", + right = "", + last_active = "", + next = "", + }, + } + end, +} + +return plugins diff --git a/lua/custom/plugins/nvim-tree.lua b/lua/custom/plugins/nvim-tree.lua new file mode 100644 index 00000000..80ecd319 --- /dev/null +++ b/lua/custom/plugins/nvim-tree.lua @@ -0,0 +1,13 @@ +return { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + keys = { + { 'e', 'NvimTreeToggle', desc = 'Explorer (NvimTree)' }, + }, + opts = {}, + config = function(_, opts) + require('nvim-tree').setup(opts) + end, +} diff --git a/lua/custom/plugins/obsidian.lua b/lua/custom/plugins/obsidian.lua new file mode 100644 index 00000000..983607d7 --- /dev/null +++ b/lua/custom/plugins/obsidian.lua @@ -0,0 +1,72 @@ +return { + 'epwalsh/obsidian.nvim', + version = '*', -- Use the latest release + lazy = true, + event = { + -- Load obsidian.nvim only when opening files in the vault + 'BufReadPre ' + .. vim.fn.expand '~/AdisObsidianVault' + .. '/*.md', + 'BufNewFile ' .. vim.fn.expand '~/AdisObsidianVault' .. '/*.md', + }, + + dependencies = { + 'nvim-lua/plenary.nvim', -- Required dependency + }, + + opts = function(_, opts) + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'markdown', 'md' }, + callback = function() + vim.wo.conceallevel = 1 + end, + }) + return { + workspaces = { + { + name = 'work', + path = '~/AdisObsidianVault', -- Define your vault path + }, + }, + templates = { + folder = '~/AdisObsidianVault/Templates', + date_format = '%d.%m.%Y', + time_format = '%H:%M', + }, + -- Optional, completion of wiki links, local markdown links, and tags using nvim-cmp. + completion = { + -- Set to false to disable completion. + nvim_cmp = true, + -- Trigger completion at 2 chars. + min_chars = 2, + }, + + ui = { + -- recommended here: https://github.com/MeanderingProgrammer/render-markdown.nvim + enabled = false, + }, + + note_id_func = function(title) + -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. + -- In this case a note with the title 'My new note' will be given an ID that looks + -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' + local suffix = '' + if title ~= nil then + -- If title is given, transform it into valid file name. + suffix = title:gsub(' ', '-'):gsub('[^A-Za-z0-9-]', ''):lower() + else + -- If title is nil, just add 4 random uppercase letters to the suffix. + for _ = 1, 4 do + suffix = suffix .. string.char(math.random(65, 90)) + end + end + return tostring(os.time()) .. '-' .. suffix + end, + + note_path_func = function(spec) + local path = spec.dir / tostring(spec.title) + return path:with_suffix '.md' + end, + } + end, +} diff --git a/lua/custom/plugins/plenary.lua b/lua/custom/plugins/plenary.lua new file mode 100644 index 00000000..d3e0f62a --- /dev/null +++ b/lua/custom/plugins/plenary.lua @@ -0,0 +1,3 @@ +return { + 'nvim-lua/plenary.nvim', +} diff --git a/lua/custom/plugins/render-markdown.lua b/lua/custom/plugins/render-markdown.lua new file mode 100644 index 00000000..533b6a4c --- /dev/null +++ b/lua/custom/plugins/render-markdown.lua @@ -0,0 +1,9 @@ +return { + "MeanderingProgrammer/render-markdown.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, +} diff --git a/lua/custom/plugins/tasko.lua b/lua/custom/plugins/tasko.lua new file mode 100644 index 00000000..c9f23489 --- /dev/null +++ b/lua/custom/plugins/tasko.lua @@ -0,0 +1,13 @@ +return { + 'adi-de-masi/tasko.nvim', + -- dir = '/Users/adidemasi/code/tasko.nvim', + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-telescope/telescope.nvim' }, + }, + config = function() + require('tasko').setup { + provider = 'todoist', + } + end, +} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 00000000..cf9dd307 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,37 @@ +return { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "tt", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "tb", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "ts", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "tl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "tL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "tQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, +} diff --git a/lua/custom/plugins/typescript-tools.lua b/lua/custom/plugins/typescript-tools.lua new file mode 100644 index 00000000..ba7fb204 --- /dev/null +++ b/lua/custom/plugins/typescript-tools.lua @@ -0,0 +1,5 @@ +return { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + opts = {}, +} diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 00000000..3f4507a7 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,118 @@ +-- Adi's custom section +local map = vim.keymap.set +--local unmap = vim.keymap.del + +-- Neovim 0.11+ ships default LSP keymaps in `vim/_defaults.lua` (e.g. `grr`, `gri`, `grt`), +-- but those use the built-in UI (often a locations list / read-only buffer). +-- Override them here to prefer Telescope pickers. +local function telescope_lsp(picker, fallback, picker_opts) + return function() + local ok, builtin = pcall(require, 'telescope.builtin') + if ok and type(builtin[picker]) == 'function' then + return builtin[picker](picker_opts or {}) + end + return fallback() + end +end + +map('n', 'gr', telescope_lsp('lsp_references', vim.lsp.buf.references), { desc = 'LSP: references (telescope)' }) +map('n', 'gi', telescope_lsp('lsp_implementations', vim.lsp.buf.implementation), { desc = 'LSP: implementations (telescope)' }) +map('n', 'gt', telescope_lsp('lsp_type_definitions', vim.lsp.buf.type_definition), { desc = 'LSP: type definitions (telescope)' }) +map('n', 'gO', telescope_lsp('lsp_document_symbols', vim.lsp.buf.document_symbol), { desc = 'LSP: document symbols (telescope)' }) + +map('n', ';', ':', { desc = 'CMD enter command mode' }) +map('i', 'jk', '') +map('n', 'lw', function() + vim.diagnostic.setloclist() +end, { desc = 'Diagnostic setloclist' }) + +map('n', 'h', 'nohlsearch', { desc = 'set no highlight search' }) +map('n', '', ' m .+1==', { desc = 'Move line down' }) +map('n', '', ' m .-2==', { desc = 'Move line up' }) +map('v', '', ":m '>+1gv=gv", { desc = 'Move selected block down' }) +map('v', '', ":m '<-2gv=gv", { desc = 'Move selected block up' }) +map('v', 'y', '"*y', { desc = 'Yank to clipboard' }) + +map('n', 'w', ':w ', { desc = 'alias to :w' }) +map('n', '', 'NvimTmuxNavigateLeft', { silent = true }) +map('n', '', 'NvimTmuxNavigateDown', { silent = true }) +map('n', '', 'NvimTmuxNavigateUp', { silent = true }) +map('n', '', 'NvimTmuxNavigateRight', { silent = true }) +map('n', '', 'NvimTmuxNavigateLastActive', { silent = true }) +map('n', 'm', 'MarkdownPreview', { silent = true }) +map('n', 'gg', ' LazyGit ', { desc = 'start LazyGit' }) + +map('n', 'd', ' Run/Debug') +map('n', 'fe', 'Telescope emoji', { desc = '😃 [F]ind [E]moji' }) +map('n', 'l', ' Lsp') + +map('n', 't', ' Telescope or  Trouble') +map('n', 'tr', 'Telescope resume') +map('n', 'o', ' Obsidian') +map('n', 'r', ' Render Markdown') +map('n', 'rt', 'RenderMarkdown toggle', { desc = 'toggle render markdown', silent = true }) +map('n', 're', 'RenderMarkdown expand', { desc = 'Increase anti-conceal margin above and below by 1', silent = true }) +map('n', 're', 'RenderMarkdown expand', { desc = 'Decrease anti-conceal margin above and below by 1', silent = true }) +map('n', 'os', 'ObsidianSearch', { silent = true }) +map('n', 'ob', 'ObsidianBacklink', { silent = true }) +map('n', 'ot', 'ObsidianToday', { silent = true }) +map('n', 'od', 'ObsidianDailies', { silent = true }) +map('n', 'oq', 'ObsidianQuickSwitch', { silent = true }) +map('n', 'on', 'ObsidianNew', { silent = true }) + +map('n', 'e', 'NvimTreeFindFileToggle', { silent = true }) +map('n', '', 'bn', { desc = 'next buffer' }) +map('n', '', 'bp', { desc = 'previous buffer' }) +map('n', 'x', 'bd', { desc = 'delete buffer' }) + +map('n', 'X', ':only', { desc = 'Close other panes' }) + +-- TJs kickstart +-- +-- +-- [[ Basic Keymaps ]] +-- See `:help map()` + +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` +--map('n', '', 'nohlsearch') + +-- Diagnostic keymaps +map('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier +-- for people to discover. Otherwise, you normally need to press , which +-- is not what someone will guess without a bit more experience. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +map('t', '', '', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +-- map('n', '', 'echo "Use h to move!!"') +-- map('n', '', 'echo "Use l to move!!"') +-- map('n', '', 'echo "Use k to move!!"') +-- map('n', '', 'echo "Use j to move!!"') + +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- +-- See `:help wincmd` for a list of all window commands +-- map('n', '', '', { desc = 'Move focus to the left window' }) +-- map('n', '', '', { desc = 'Move focus to the right window' }) +-- map('n', '', '', { desc = 'Move focus to the lower window' }) +-- map('n', '', '', { desc = 'Move focus to the upper window' }) + +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +})