Customizations based on previous config

probably still bloated
This commit is contained in:
Adi De Masi 2025-12-19 12:58:12 +01:00
parent 3338d39206
commit 68cdfcc3a3
17 changed files with 703 additions and 56 deletions

View File

@ -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! :) 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 <space> as the leader key -- Set <space> as the leader key
-- See `:help mapleader` -- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' ' vim.g.mapleader = ','
vim.g.maplocalleader = ' ' 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 -- 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 ]] -- [[ Setting options ]]
-- See `:help vim.o` -- See `:help vim.o`
@ -100,6 +107,9 @@ vim.g.have_nerd_font = false
-- Make line numbers default -- Make line numbers default
vim.o.number = true vim.o.number = true
require 'keymaps'
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it! -- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true -- vim.o.relativenumber = true
@ -344,7 +354,7 @@ require('lazy').setup({
-- Document existing key chains -- Document existing key chains
spec = { spec = {
{ '<leader>s', group = '[S]earch' }, { '<leader>f', group = '[F]ind' },
{ '<leader>t', group = '[T]oggle' }, { '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, { '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
}, },
@ -426,15 +436,15 @@ require('lazy').setup({
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
local builtin = require 'telescope.builtin' local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = '[F]ind [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', '<leader>fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = '[F]ind [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', '<leader>fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', '<leader>fw', builtin.grep_string, { desc = '[F]ind current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = '[F]ind by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', '<leader>fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', '<leader>fr', builtin.resume, { desc = '[F]ind [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Slightly advanced example of overriding default behavior and theme -- 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. -- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys -- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set('n', '<leader>s/', function() vim.keymap.set('n', '<leader>f/', function()
builtin.live_grep { builtin.live_grep {
grep_open_files = true, grep_open_files = true,
prompt_title = 'Live Grep in Open Files', 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 -- Shortcut for searching your Neovim configuration files
vim.keymap.set('n', '<leader>sn', function() vim.keymap.set('n', '<leader>fn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' } builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' }) end, { desc = '[F]ind [N]eovim files' })
end, end,
}, },
@ -535,43 +545,8 @@ require('lazy').setup({
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end end
-- Rename the variable under your cursor. -- Check out lua/custom/plugins/lsp.lua for more lsp related keymaps
-- 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 <C-t>.
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')
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client ---@param client vim.lsp.Client
---@param method vim.lsp.protocol.Method ---@param method vim.lsp.protocol.Method
@ -742,7 +717,7 @@ require('lazy').setup({
cmd = { 'ConformInfo' }, cmd = { 'ConformInfo' },
keys = { keys = {
{ {
'<leader>f', '<leader>F',
function() function()
require('conform').format { async = true, lsp_format = 'fallback' } require('conform').format { async = true, lsp_format = 'fallback' }
end, end,
@ -984,7 +959,7 @@ require('lazy').setup({
-- This is the easiest way to modularize your config. -- 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. -- 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` -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope! -- Or use telescope!

View File

@ -0,0 +1 @@
return { 'akinsho/bufferline.nvim', version = '*', dependencies = 'nvim-tree/nvim-web-devicons' }

View File

@ -0,0 +1,93 @@
return {
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{
-- Customize or remove this keymap to your liking
'<leader>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,
}

View File

@ -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 = '<M-]>',
prev = '<M-[>',
dismiss = '<C-]>',
},
},
panel = { enabled = true },
}
end,
}

View File

@ -0,0 +1,8 @@
return {
"kdheepak/lazygit.nvim",
cmd = "LazyGit",
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
}

229
lua/custom/plugins/lsp.lua Normal file
View File

@ -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', '<leader>e', vim.diagnostic.open_float, opts)
-- vim.keymap.set('n', '<leader>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',
'<leader>ls',
telescope_lsp('lsp_document_symbols', vim.lsp.buf.document_symbol),
bufoptsWithDesc 'Open symbol picker'
)
vim.keymap.set(
'n',
'<leader>lS',
telescope_lsp('lsp_dynamic_workspace_symbols', vim.lsp.buf.workspace_symbol),
bufoptsWithDesc 'Open symbol picker (workspace)'
)
vim.keymap.set(
'n',
'<leader>dd',
telescope_lsp('diagnostics', vim.diagnostic.setloclist),
bufoptsWithDesc 'Open diagnostics picker'
)
-- Enable completion triggered by <c-x><c-o>
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', '<C-k>', vim.lsp.buf.signature_help, bufoptsWithDesc("Signature help"))
-- vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufoptsWithDesc(""))
-- vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufoptsWithDesc())
-- vim.keymap.set('n', '<leader>wl', function()
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
-- end, bufoptsWithDesc())
vim.keymap.set('n', '<leader>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('<C-f>', 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', '<leader>lw', function()
vim.diagnostic.setloclist()
end, { desc = 'Diagnostic setloclist' })
vim.keymap.set('n', '<leader>la', vim.lsp.buf.code_action, bufoptsWithDesc 'Run code action')
-- vim.keymap.set('n', '<leader>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,
}

View File

@ -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" },
}

View File

@ -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,
}

View File

@ -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 = "<C-h>",
down = "<C-j>",
up = "<C-k>",
right = "<C-l>",
last_active = "<C-\\>",
next = "<C-Space>",
},
}
end,
}
return plugins

View File

@ -0,0 +1,13 @@
return {
'nvim-tree/nvim-tree.lua',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
keys = {
{ '<leader>e', '<cmd>NvimTreeToggle<CR>', desc = 'Explorer (NvimTree)' },
},
opts = {},
config = function(_, opts)
require('nvim-tree').setup(opts)
end,
}

View File

@ -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,
}

View File

@ -0,0 +1,3 @@
return {
'nvim-lua/plenary.nvim',
}

View File

@ -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 = {},
}

View File

@ -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,
}

View File

@ -0,0 +1,37 @@
return {
"folke/trouble.nvim",
opts = {}, -- for default options, refer to the configuration section for custom setup.
cmd = "Trouble",
keys = {
{
"<leader>tt",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>tb",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>ts",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>tl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>tL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>tQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
}

View File

@ -0,0 +1,5 @@
return {
'pmizio/typescript-tools.nvim',
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
opts = {},
}

118
lua/keymaps.lua Normal file
View File

@ -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', '<ESC>')
map('n', '<leader>lw', function()
vim.diagnostic.setloclist()
end, { desc = 'Diagnostic setloclist' })
map('n', '<leader>h', '<cmd>nohlsearch<CR>', { desc = 'set no highlight search' })
map('n', '<A-j>', '<cmd> m .+1<CR>==', { desc = 'Move line down' })
map('n', '<A-k>', '<cmd> m .-2<CR>==', { desc = 'Move line up' })
map('v', '<A-j>', ":m '>+1<CR>gv=gv", { desc = 'Move selected block down' })
map('v', '<A-k>', ":m '<-2<CR>gv=gv", { desc = 'Move selected block up' })
map('v', '<leader>y', '"*y', { desc = 'Yank to clipboard' })
map('n', '<leader>w', ':w <CR>', { desc = 'alias to :w' })
map('n', '<C-h>', '<Cmd>NvimTmuxNavigateLeft<CR>', { silent = true })
map('n', '<C-j>', '<Cmd>NvimTmuxNavigateDown<CR>', { silent = true })
map('n', '<C-k>', '<Cmd>NvimTmuxNavigateUp<CR>', { silent = true })
map('n', '<C-l>', '<Cmd>NvimTmuxNavigateRight<CR>', { silent = true })
map('n', '<C-\\>', '<Cmd>NvimTmuxNavigateLastActive<CR>', { silent = true })
map('n', '<leader>m', '<Cmd>MarkdownPreview<CR>', { silent = true })
map('n', '<leader>gg', '<Cmd> LazyGit <CR>', { desc = 'start LazyGit' })
map('n', '<leader>d', ' Run/Debug')
map('n', '<leader>fe', '<Cmd>Telescope emoji<CR>', { desc = '😃 [F]ind [E]moji' })
map('n', '<leader>l', ' Lsp')
map('n', '<leader>t', ' Telescope or  Trouble')
map('n', '<leader>tr', '<Cmd>Telescope resume<CR>')
map('n', '<leader>o', ' Obsidian')
map('n', '<leader>r', ' Render Markdown')
map('n', '<leader>rt', '<Cmd>RenderMarkdown toggle<CR>', { desc = 'toggle render markdown', silent = true })
map('n', '<leader>re', '<Cmd>RenderMarkdown expand<CR>', { desc = 'Increase anti-conceal margin above and below by 1', silent = true })
map('n', '<leader>re', '<Cmd>RenderMarkdown expand<CR>', { desc = 'Decrease anti-conceal margin above and below by 1', silent = true })
map('n', '<leader>os', '<Cmd>ObsidianSearch<CR>', { silent = true })
map('n', '<leader>ob', '<Cmd>ObsidianBacklink<CR>', { silent = true })
map('n', '<leader>ot', '<Cmd>ObsidianToday<CR>', { silent = true })
map('n', '<leader>od', '<Cmd>ObsidianDailies<CR>', { silent = true })
map('n', '<leader>oq', '<Cmd>ObsidianQuickSwitch<CR>', { silent = true })
map('n', '<leader>on', '<Cmd>ObsidianNew<CR>', { silent = true })
map('n', '<leader>e', '<Cmd>NvimTreeFindFileToggle<CR>', { silent = true })
map('n', '<leader><Tab>', '<Cmd>bn<CR>', { desc = 'next buffer' })
map('n', '<leader><S-Tab>', '<Cmd>bp<CR>', { desc = 'previous buffer' })
map('n', '<leader>x', '<Cmd>bd<CR>', { desc = 'delete buffer' })
map('n', 'X', ':only<CR>', { desc = 'Close other panes' })
-- TJs kickstart
--
--
-- [[ Basic Keymaps ]]
-- See `:help map()`
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
--map('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps
map('n', '<leader>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 <C-\><C-n>, 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 <C-\><C-n> to exit terminal mode
map('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
-- TIP: Disable arrow keys in normal mode
-- map('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- map('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- map('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- map('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
-- map('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
-- map('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
-- map('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
-- map('n', '<C-k>', '<C-w><C-k>', { 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,
})