diff --git a/init.lua b/init.lua index 220d3045..a8443d54 100644 --- a/init.lua +++ b/init.lua @@ -90,14 +90,45 @@ P.S. You can delete this when you're done too. It's your config now! :) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' +-- Add the clipboard configuration for win32yank +if vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then + vim.g.clipboard = { + name = 'win32yank-wsl', + copy = { + ['+'] = 'win32yank.exe -i --crlf', + ['*'] = 'win32yank.exe -i --crlf', + }, + paste = { + ['+'] = 'win32yank.exe -o --lf', + ['*'] = 'win32yank.exe -o --lf', + }, + cache_enabled = 0, + } +end + -- 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.opt` -- NOTE: You can change these options as you wish! -- For more options, you can see `:help option-list` +-- Create the spell directory if it doesn't exist +local spell_dir = vim.fn.stdpath 'config' .. '/spell' +if vim.fn.isdirectory(spell_dir) == 0 then + vim.fn.mkdir(spell_dir, 'p') +end + +-- Set the spellfile option +vim.opt.spellfile = spell_dir .. '/en.utf-8.add' + +-- Ensure the spellfile exists +local spellfile_path = spell_dir .. '/en.utf-8.add' +if vim.fn.filereadable(spellfile_path) == 0 then + vim.fn.writefile({}, spellfile_path) +end + -- Make line numbers default vim.opt.number = true -- You can also add relative line numbers, to help with jumping. @@ -160,6 +191,11 @@ vim.opt.scrolloff = 10 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +-- Key mapping to toggle DAP UI +vim.keymap.set('n', 'dui', function() + require('dapui').toggle() +end) + -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') @@ -176,10 +212,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -190,6 +226,24 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- [[ Custom Keymaps ]] + +-- Keymap to close the current buffer but keep split windows open +vim.keymap.set('n', 'bD', ':bp | bd #', { noremap = true, silent = true, desc = "Close buffer but keep split" }) + + +-- Vim Rest Console +vim.keymap.set('n', 'r', ':Vrc', { noremap = true, silent = true }) + +-- Navigate to the next buffer +vim.keymap.set('n', 'bn', ':bnext', { desc = 'Next buffer' }) + +-- Navigate to the previous buffer +vim.keymap.set('n', 'bp', ':bprevious', { desc = 'Previous buffer' }) + +-- Close the current buffer +vim.keymap.set('n', 'bd', ':bd', { desc = 'Close buffer' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -207,7 +261,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.uv.fs_stat(lazypath) then +if not vim.loop.fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } if vim.v.shell_error ~= 0 then @@ -228,6 +282,12 @@ vim.opt.rtp:prepend(lazypath) -- -- NOTE: Here is where you install your plugins. require('lazy').setup({ + + --spec = { + --{ 'LazyVim/LazyVim', import = 'lazyvim.plugins' }, + --{ import = 'custom.plugins' }, + --}, + -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically @@ -255,6 +315,57 @@ require('lazy').setup({ }, }, }, + { + 'windwp/nvim-ts-autotag', + }, + { + 'vhyrro/luarocks.nvim', + opts = { + luarocks_build_args = { + '--with-lua-include=/usr/include', + }, + }, + }, + { import = 'custom.plugins.noice' }, + { import = 'custom.plugins.notify' }, + { + 'nvimdev/dashboard-nvim', + event = 'VimEnter', + config = function() + require('dashboard').setup { + theme = 'doom', + config = { + header = {}, + center = { + { + desc = ' Files', + group = 'Label', + action = 'Telescope find_files', + key = 'f', + }, + { desc = '󰊳 Update', group = '@property', action = 'Lazy update', key = 'u' }, + { + desc = '\u{1F5CA} Notes', + group = 'DiagnosticHint', + action = 'Neorg index', + key = 'n', + }, + { + desc = 'Projects', + group = 'work', + action = 'e ~/Projects', + key = 'p', + }, + }, + footer = {}, + week_header = { + enable = true, + }, + }, + } + end, + dependencies = { { 'nvim-tree/nvim-web-devicons' } }, + }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- @@ -340,7 +451,6 @@ require('lazy').setup({ -- This opens a window that shows you all of the keymaps for the current -- Telescope picker. This is really useful to discover what Telescope can -- do as well as how to actually do it! - -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { @@ -399,6 +509,11 @@ require('lazy').setup({ vim.keymap.set('n', 'sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' }) + + -- Shortcut for searching Obsidian files + vim.keymap.set('n', 'so', function() + builtin.find_files { cwd = '~/Obsidian/vaults/' } + end, { desc = '[S]earch [O]bsidian files' }) end, }, @@ -840,36 +955,105 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - config = function(_, opts) - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup(opts) - - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + { + 'olrtg/nvim-emmet', + config = function() + vim.keymap.set({ 'n', 'v' }, 'xe', require('nvim-emmet').wrap_with_abbreviation) end, }, + { + 'nvim-treesitter/nvim-treesitter', + version = false, -- last release is way too old and doesn't work on Windows + build = ':TSUpdate', + event = { 'BufRead', 'BufNewFile' }, + lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline + init = function(plugin) + -- PERF: add nvim-treesitter queries to the rtp and its custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer triggers the **nvim-treesitter** module to be loaded in time. + -- Luckily, the only things that those plugins need are the custom queries, which we make available + -- during startup. + require('lazy.core.loader').add_to_rtp(plugin) + require 'nvim-treesitter.query_predicates' + end, + cmd = { 'TSUpdateSync', 'TSUpdate', 'TSInstall' }, + keys = { + { '', desc = 'Increment Selection' }, + { '', desc = 'Decrement Selection', mode = 'x' }, + }, + opts_extend = { 'ensure_installed' }, + ---@type TSConfig + ---@diagnostic disable-next-line: missing-fields + opts = { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'javascript', + 'jsdoc', + 'json', + 'jsonc', + 'lua', + 'luadoc', + 'luap', + 'markdown', + 'markdown_inline', + 'printf', + 'python', + 'query', + 'regex', + 'toml', + 'tsx', + 'typescript', + 'vim', + 'vimdoc', + 'xml', + 'yaml', + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = false, + node_decremental = '', + }, + }, + textobjects = { + move = { + enable = true, + goto_next_start = { [']f'] = '@function.outer', [']c'] = '@class.outer', [']a'] = '@parameter.inner' }, + goto_next_end = { [']F'] = '@function.outer', [']C'] = '@class.outer', [']A'] = '@parameter.inner' }, + goto_previous_start = { ['[f'] = '@function.outer', ['[c'] = '@class.outer', ['[a'] = '@parameter.inner' }, + goto_previous_end = { ['[F'] = '@function.outer', ['[C'] = '@class.outer', ['[A'] = '@parameter.inner' }, + }, + }, + }, + ---@param opts TSConfig + config = function(_, opts) + -- Ensure the list is deduplicated manually + if type(opts.ensure_installed) == 'table' then + local seen = {} + local deduped = {} + for _, item in ipairs(opts.ensure_installed) do + if not seen[item] then + table.insert(deduped, item) + seen[item] = true + end + end + opts.ensure_installed = deduped + end + require('nvim-treesitter.configs').setup(opts) + end, + }, + { + 'windwp/nvim-ts-autotag', + after = 'nvim-treesitter', + opts = {}, + }, -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and @@ -880,19 +1064,57 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.debug', + --require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- 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. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, + + -- Custom Plugins + + -- Transparent Background + require 'custom.plugins.transparent', + + -- Neorg + require 'custom.plugins.neorg', + + -- Cattpuccin Theme + require 'custom.plugins.cattpuccin', + + -- Obsidian + require 'custom.plugins.obsidian', + + -- Lua Line + require 'custom.plugins.lualine', + + -- Git Fugitive + require 'custom.plugins.git-fugitive', + + -- Lazy Git + require 'custom.plugins.lazy-git', + + -- Dad Bod + require 'custom.plugins.dadbod', + + -- Dad Bod UI + require 'custom.plugins.dadbod-ui', + + -- Dad Bod Completion + require 'custom.plugins.dad-bod-completion', + + -- Dap Debugg + require 'custom.plugins.dap', + + -- Completion + require 'custom.plugins.completion', }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lazyvim.json b/lazyvim.json new file mode 100644 index 00000000..8e6b0ec7 --- /dev/null +++ b/lazyvim.json @@ -0,0 +1,9 @@ +{ + "extras": [ + + ], + "news": { + "NEWS.md": "6520" + }, + "version": 6 +} \ No newline at end of file diff --git a/lua/custom/plugins/auto-tag.lua b/lua/custom/plugins/auto-tag.lua new file mode 100644 index 00000000..411b8445 --- /dev/null +++ b/lua/custom/plugins/auto-tag.lua @@ -0,0 +1,6 @@ +return { + { + 'windwp/nvim-ts-autotag', + after = 'nvim-treesitter', + }, +} diff --git a/lua/custom/plugins/cattpuccin.lua b/lua/custom/plugins/cattpuccin.lua new file mode 100644 index 00000000..8fa22d20 --- /dev/null +++ b/lua/custom/plugins/cattpuccin.lua @@ -0,0 +1,61 @@ +-- Catppuccin is a Neovim theme plugin with flexible color schemes +-- https://github.com/catppuccin/nvim + +return { + 'catppuccin/nvim', -- GitHub repository + as = 'catppuccin', -- Optional: rename the plugin to 'catppuccin' + version = '*', -- Use the latest version + dependencies = { + 'kyazdani42/nvim-web-devicons', -- Recommended for file icons + }, + config = function() + require('catppuccin').setup { + flavour = 'frappe', -- Choose from "latte", "frappe", "macchiato", "mocha" + background = { + light = 'latte', + dark = 'mocha', + }, + transparent_background = false, + show_end_of_buffer = true, + term_colors = true, + dim_inactive = { + enabled = true, + shade = 'dark', + percentage = 0.15, + }, + styles = { + comments = { 'italic' }, + conditionals = { 'italic' }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + default_integrations = true, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = false, + mini = { + enabled = true, + indentscope_color = 'auto', + }, + }, + } + + -- Set the colorscheme + vim.cmd 'colorscheme catppuccin' + end, +} + + diff --git a/lua/custom/plugins/completion.lua b/lua/custom/plugins/completion.lua new file mode 100644 index 00000000..e0d27b9f --- /dev/null +++ b/lua/custom/plugins/completion.lua @@ -0,0 +1,67 @@ +-- ~/.config/nvim/lua/custom/plugins/completion.lua + +return { + -- Completion framework + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + config = function() + local cmp = require 'cmp' + cmp.setup { + snippet = { + expand = function(args) + vim.fn['vsnip#anonymous'](args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('(vsnip-expand-or-jump)', true, true, true), '') + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn['vsnip#jumpable'](-1) == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('(vsnip-jump-prev)', true, true, true), '') + else + fallback() + end + end, { 'i', 's' }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + }, { + { name = 'buffer' }, + }), + } + end, + }, + + -- LSP completion source + { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' }, + + -- Buffer completion source + { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' }, + + -- Path completion source + { 'hrsh7th/cmp-path', after = 'nvim-cmp' }, + + -- Snippet completion source + { 'hrsh7th/cmp-vsnip', after = 'nvim-cmp' }, + + -- Snippet engine + { 'hrsh7th/vim-vsnip', event = 'InsertEnter' }, +} diff --git a/lua/custom/plugins/dad-bod-completion.lua b/lua/custom/plugins/dad-bod-completion.lua new file mode 100644 index 00000000..3200ad24 --- /dev/null +++ b/lua/custom/plugins/dad-bod-completion.lua @@ -0,0 +1,3 @@ +return { + 'kristijanhusak/vim-dadbod-completion', +} diff --git a/lua/custom/plugins/dadbod-ui.lua b/lua/custom/plugins/dadbod-ui.lua new file mode 100644 index 00000000..4a2fd7a7 --- /dev/null +++ b/lua/custom/plugins/dadbod-ui.lua @@ -0,0 +1,3 @@ +return { + 'kristijanhusak/vim-dadbod-ui', +} diff --git a/lua/custom/plugins/dadbod.lua b/lua/custom/plugins/dadbod.lua new file mode 100644 index 00000000..42bd50d1 --- /dev/null +++ b/lua/custom/plugins/dadbod.lua @@ -0,0 +1,3 @@ +return { + 'tpope/vim-dadbod', +} diff --git a/lua/custom/plugins/dap.lua b/lua/custom/plugins/dap.lua new file mode 100644 index 00000000..fc3dca78 --- /dev/null +++ b/lua/custom/plugins/dap.lua @@ -0,0 +1,118 @@ +return { + { + 'mfussenegger/nvim-dap', + dependencies = { + 'leoluz/nvim-dap-go', + 'rcarriga/nvim-dap-ui', + 'theHamsta/nvim-dap-virtual-text', + 'nvim-neotest/nvim-nio', + 'williamboman/mason.nvim', + }, + config = function() + local dap = require 'dap' + local ui = require 'dapui' + + require('dapui').setup() + require('dap-go').setup() + require('nvim-dap-virtual-text').setup {} + + -- Configuration for .NET Core (ASP.NET Core) using net8.0 + dap.adapters.coreclr = { + type = 'executable', + command = '/usr/local/bin/netcoredbg/netcoredbg', -- Update with the correct path to netcoredbg + args = { '--interpreter=vscode' }, + } + + dap.configurations.cs = { + { + type = 'coreclr', + name = 'Launch ASP.NET Core', + request = 'launch', + preLaunchTask = function() + -- Run the project before launching the debugger + local build_cmd = 'dotnet publish --configuration Debug --runtime linux-x64 --self-contained' + print('Running: ' .. build_cmd) + vim.fn.system(build_cmd) + end, + program = function() + local cwd = vim.fn.getcwd() + local dll = vim.fn.glob(cwd .. '/bin/Debug/net8.0/linux-x64/MelodyFitnessApi.dll', 0, 1) + if #dll == 0 then + print 'No DLL found in bin/Debug/net8.0/linux-x64' + return '' + end + print('Using program: ' .. dll[1]) + return dll[1] + end, + cwd = '${workspaceFolder}', + stopAtEntry = false, + console = 'integratedTerminal', + }, + { + type = 'coreclr', + name = 'Attach ASP.NET Core', + request = 'attach', + processId = require('dap.utils').pick_process, + cwd = '${workspaceFolder}', + }, + } + + -- Configuration for Ionic Angular (JavaScript/TypeScript) using Firefox + dap.adapters.chrome = { + type = 'executable', + command = 'node', + args = { os.getenv 'HOME' .. '/.vscode/extensions/vscode-chrome-debug/out/src/chromeDebug.js' }, + } + dap.configurations.javascript = { + { + type = 'chrome', + name = 'Attach to Chrome (Ionic App)', + request = 'attach', + program = '${file}', + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = 'inspector', + port = 9222, -- Port where Chrome is listening + url = 'https://localhost:8100/login', -- URL of your running Ionic app + webRoot = '${workspaceFolder}', + timeout = 20000, -- Optional: Increase if you experience timeouts + address = '0.0.0.0', + }, + } + + dap.configurations.typescript = dap.configurations.javascript + + vim.keymap.set('n', 'tb', dap.toggle_breakpoint) + vim.keymap.set('n', 'gb', dap.run_to_cursor) + + vim.keymap.set('n', '?', function() + require('dapui').eval(nil, { enter = true }) + end) + + vim.keymap.set('n', '', dap.continue) + vim.keymap.set('n', '', dap.step_into) + vim.keymap.set('n', '', dap.step_over) + vim.keymap.set('n', '', dap.step_out) + vim.keymap.set('n', '', dap.step_back) + vim.keymap.set('n', '', dap.restart) + + -- Key mapping to toggle the DAP UI + vim.keymap.set('n', 'dui', function() + ui.toggle() + end) + + dap.listeners.before.attach.dapui_config = function() + ui.open() + end + dap.listeners.before.launch.dapui_config = function() + ui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + ui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + ui.close() + end + end, + }, +} diff --git a/lua/custom/plugins/git-fugitive.lua b/lua/custom/plugins/git-fugitive.lua new file mode 100644 index 00000000..b6b4c97b --- /dev/null +++ b/lua/custom/plugins/git-fugitive.lua @@ -0,0 +1,3 @@ +return { + 'tpope/vim-fugitive', +} diff --git a/lua/custom/plugins/lazy-git.lua b/lua/custom/plugins/lazy-git.lua new file mode 100644 index 00000000..f0bbd383 --- /dev/null +++ b/lua/custom/plugins/lazy-git.lua @@ -0,0 +1,19 @@ +return { + 'kdheepak/lazygit.nvim', + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { 'lg', 'LazyGit', desc = 'LazyGit' }, + }, +} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..cc9a072f --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,46 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'catppuccin', + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'buffers' }, -- Show buffers in the main statusline + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, + } + end, +} diff --git a/lua/custom/plugins/neorg.lua b/lua/custom/plugins/neorg.lua new file mode 100644 index 00000000..af09f7fc --- /dev/null +++ b/lua/custom/plugins/neorg.lua @@ -0,0 +1,77 @@ +-- neorg_setup.lua +return { + -- Dependency for Neorg: a colorscheme compatible with treesitter + { + 'rebelot/kanagawa.nvim', + config = function() + vim.cmd.colorscheme 'kanagawa' + end, + }, + + -- Treesitter configuration necessary for Neorg + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + opts = { + ensure_installed = { 'c', 'lua', 'vim', 'vimdoc', 'query' }, + highlight = { enable = true }, + }, + config = function(_, opts) + require('nvim-treesitter.configs').setup(opts) + end, + }, + + -- Dependency manager for Neorg + { + 'vhyrro/luarocks.nvim', + priority = 1000, + config = true, + }, + + -- Main Neorg setup + { + 'nvim-neorg/neorg', + dependencies = { 'luarocks.nvim' }, + version = '*', + config = function() + require('neorg').setup { + load = { + ['core.defaults'] = {}, -- Load all the default modules + ['core.concealer'] = {}, -- Allows for use of icons + ['core.export'] = { + config = { + export_dir = '~/notes/exports', -- Sets the export directory for all files + exporters = { -- Defines the exporters available and their settings + markdown = { -- Markdown exporter settings + extensions = { 'md' }, -- Specifies the file extensions to use when exporting to Markdown + }, + html = { -- HTML exporter settings + extensions = { 'html' }, -- Specifies the file extensions to use when exporting to HTML + }, + pdf = { -- PDF exporter settings + extensions = { 'pdf' }, -- Specifies the file extensions to use when exporting to PDF + }, + }, + }, + }, + ['core.journal'] = { + config = { + workspace = 'notes', -- Specifies the workspace for journaling + }, + }, + ['core.dirman'] = { + config = { + workspaces = { + notes = '~/notes', -- Path to your notes directory + }, + default_workspace = 'notes', -- Sets default workspace + }, + }, + }, + } + vim.wo.foldlevel = 99 -- Set the foldlevel for vim + vim.wo.conceallevel = 2 -- Set the conceallevel for better visibility + end, + }, +} + diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua new file mode 100644 index 00000000..935a96c2 --- /dev/null +++ b/lua/custom/plugins/noice.lua @@ -0,0 +1,24 @@ +return { + 'folke/noice.nvim', + event = 'VeryLazy', + opts = { + -- add any options here + lsp = { + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, + }, + }, + }, + config = function() + local noice = require 'noice' + noice.setup { + -- any options for noice + } + end, + dependencies = { + 'MunifTanjim/nui.nvim', + 'rcarriga/nvim-notify', + }, +} diff --git a/lua/custom/plugins/notify.lua b/lua/custom/plugins/notify.lua new file mode 100644 index 00000000..3e43887b --- /dev/null +++ b/lua/custom/plugins/notify.lua @@ -0,0 +1,8 @@ +return { + 'rcarriga/nvim-notify', + config = function() + require('notify').setup { + background_colour = '#000000', + } + end, +} diff --git a/lua/custom/plugins/obsidian.lua b/lua/custom/plugins/obsidian.lua new file mode 100644 index 00000000..f4c53202 --- /dev/null +++ b/lua/custom/plugins/obsidian.lua @@ -0,0 +1,77 @@ +return { + 'epwalsh/obsidian.nvim', + version = '*', + lazy = false, + ft = 'markdown', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + opts = { + workspaces = { + { + name = 'personal', + path = '/home/martin/Obsidian/vaults/personal', + default_tags = { 'personal-notes' }, + overrides = { + notes_subdir = 'vaults/personal/notes/', + }, + }, + { + name = 'work', + path = '/home/martin/Obsidian/vaults/work', + default_tags = { 'work-notes' }, + overrides = { + notes_subdir = 'vaults/work/notes/', + }, + }, + { + name = 'daily', + path = '/home/martin/Obsidian/vaults/daily', + overrides = { + notes_subdir = 'notes', + }, + }, + }, + templates = { + folder = '/home/martin/Obsidian/templates', + date_format = '%Y-%m-%d', + time_format = '%H:%M', + }, + daily_notes = { + date_format = '%Y-%m-%d', + alias_format = '%B %-d, %Y', + default_tags = { 'daily-notes' }, + template = 'daily.md', + }, + completion = { + nvim_cmp = true, + min_chars = 2, + }, + mappings = { + ['gf'] = { + action = function() + return require('obsidian').util.gf_passthrough() + end, + opts = { noremap = false, expr = true, buffer = true }, + }, + }, + new_notes_location = 'notes_subdir', + note_id_func = function(title) + local suffix = '' + local current_time = os.date '%Y-%m-%d-%H%M' + if title ~= nil then + suffix = title:gsub(' ', '-'):gsub('[^A-Za-z0-9-]', ''):lower() + else + for _ = 1, 4 do + suffix = suffix .. string.char(math.random(65, 90)) + end + end + return current_time .. '-' .. suffix + end, + }, + config = function(_, opts) + require('obsidian').setup(opts) + -- Load the custom key mappings + require('obsidian_keymaps').setup_keymaps() + end, +} diff --git a/lua/custom/plugins/rest_nvim.lua b/lua/custom/plugins/rest_nvim.lua new file mode 100644 index 00000000..b8224db1 --- /dev/null +++ b/lua/custom/plugins/rest_nvim.lua @@ -0,0 +1,5 @@ +return { + -- 'rest-nvim/rest.nvim', + -- dependencies = { 'luarocks.nvim', 'nvim-lua/plenary.nvim' }, + -- config = function() end, +} diff --git a/lua/custom/plugins/transparent.lua b/lua/custom/plugins/transparent.lua new file mode 100644 index 00000000..f99e1a23 --- /dev/null +++ b/lua/custom/plugins/transparent.lua @@ -0,0 +1,24 @@ +-- transparent.nvim plugin configuration +-- https://github.com/xiyaowong/transparent.nvim + +return { + 'xiyaowong/transparent.nvim', -- GitHub repository + as = 'transparent', -- Optional: rename the plugin to 'transparent' + config = function() + require('transparent').setup({ + groups = { -- table: default groups + 'Normal', 'NormalNC', 'Comment', 'Constant', 'Special', 'Identifier', + 'Statement', 'PreProc', 'Type', 'Underlined', 'Todo', 'String', 'Function', + 'Conditional', 'Repeat', 'Operator', 'Structure', 'LineNr', 'NonText', + 'SignColumn', 'CursorLine', 'CursorLineNr', 'StatusLine', 'StatusLineNC', + 'EndOfBuffer', + }, + extra_groups = { -- extra highlight groups to clear + 'all', -- Also clear background for all highlight groups + }, + exclude_groups = {}, -- exclude these highlight groups from being cleared + }) + end, +} + + diff --git a/lua/custom/plugins/treesitter.lua b/lua/custom/plugins/treesitter.lua new file mode 100644 index 00000000..8c08ecfd --- /dev/null +++ b/lua/custom/plugins/treesitter.lua @@ -0,0 +1,96 @@ +-- ~/.config/nvim/lua/custom/plugins/treesitter.lua + +return { + { + 'nvim-treesitter/nvim-treesitter', + version = false, -- last release is way too old and doesn't work on Windows + build = ':TSUpdate', + event = { 'BufRead', 'BufNewFile' }, + lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline + init = function(plugin) + -- PERF: add nvim-treesitter queries to the rtp and its custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer triggers the **nvim-treesitter** module to be loaded in time. + -- Luckily, the only things that those plugins need are the custom queries, which we make available + -- during startup. + require('lazy.core.loader').add_to_rtp(plugin) + require 'nvim-treesitter.query_predicates' + end, + cmd = { 'TSUpdateSync', 'TSUpdate', 'TSInstall' }, + keys = { + { '', desc = 'Increment Selection' }, + { '', desc = 'Decrement Selection', mode = 'x' }, + }, + opts_extend = { 'ensure_installed' }, + ---@type TSConfig + ---@diagnostic disable-next-line: missing-fields + opts = { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'javascript', + 'jsdoc', + 'json', + 'jsonc', + 'lua', + 'luadoc', + 'luap', + 'markdown', + 'markdown_inline', + 'printf', + 'python', + 'query', + 'regex', + 'toml', + 'tsx', + 'typescript', + 'vim', + 'vimdoc', + 'xml', + 'yaml', + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = false, + node_decremental = '', + }, + }, + textobjects = { + move = { + enable = true, + goto_next_start = { [']f'] = '@function.outer', [']c'] = '@class.outer', [']a'] = '@parameter.inner' }, + goto_next_end = { [']F'] = '@function.outer', [']C'] = '@class.outer', [']A'] = '@parameter.inner' }, + goto_previous_start = { ['[f'] = '@function.outer', ['[c'] = '@class.outer', ['[a'] = '@parameter.inner' }, + goto_previous_end = { ['[F'] = '@function.outer', ['[C'] = '@class.outer', ['[A'] = '@parameter.inner' }, + }, + }, + }, + ---@param opts TSConfig + config = function(_, opts) + -- Ensure the list is deduplicated manually + if type(opts.ensure_installed) == 'table' then + local seen = {} + local deduped = {} + for _, item in ipairs(opts.ensure_installed) do + if not seen[item] then + table.insert(deduped, item) + seen[item] = true + end + end + opts.ensure_installed = deduped + end + require('nvim-treesitter.configs').setup(opts) + end, + }, + { + 'windwp/nvim-ts-autotag', + after = 'nvim-treesitter', + }, +} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index ca9bc237..d61a1ecc 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -6,7 +6,7 @@ return { config = function() local lint = require 'lint' lint.linters_by_ft = { - markdown = { 'markdownlint' }, + markdown = {}, } -- To allow other plugins to add linters to require('lint').linters_by_ft, diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index f126d68a..4db45965 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -18,6 +18,48 @@ return { window = { mappings = { ['\\'] = 'close_window', + -- Add a new key mapping to open a terminal in a floating window + ['t'] = { + function(state) + -- Save the original working directory + local original_dir = vim.fn.getcwd() + + -- Retrieve the current path from the NeoTree state + local current_dir = state.tree:get_node().path + if vim.fn.isdirectory(current_dir) == 0 then + current_dir = vim.fn.fnamemodify(current_dir, ':h') + end + vim.cmd('cd ' .. current_dir) + + -- Configure floating window options + local width = math.floor(vim.o.columns * 0.8) + local height = math.floor(vim.o.lines * 0.8) + local opts = { + relative = 'editor', + width = width, + height = height, + col = math.floor((vim.o.columns - width) / 2), + row = math.floor((vim.o.lines - height) / 2), + style = 'minimal', + border = 'rounded', -- Other options: 'single', 'double', 'solid', 'shadow' + } + + -- Create a new buffer for the terminal + local buf = vim.api.nvim_create_buf(false, true) + local win = vim.api.nvim_open_win(buf, true, opts) + + -- Start terminal in the floating window + vim.fn.termopen(vim.o.shell) + vim.cmd 'startinsert' + + -- Set a keymap to close the floating terminal window + vim.api.nvim_buf_set_keymap(buf, 't', '', ':q!', { noremap = true, silent = true }) + + -- Restore the original working directory + vim.cmd('cd ' .. original_dir) + end, + desc = 'Open terminal in a floating window at current directory', -- Description for the keymap + }, }, }, }, diff --git a/lua/obsidian_keymaps.lua b/lua/obsidian_keymaps.lua new file mode 100644 index 00000000..e646548f --- /dev/null +++ b/lua/obsidian_keymaps.lua @@ -0,0 +1,49 @@ +local M = {} + +-- Function to create a new personal note +function M.new_personal_note() + vim.cmd 'ObsidianWorkspace personal' + vim.cmd 'ObsidianNew' +end + +-- Function to create a new work note +function M.new_work_note() + vim.cmd 'ObsidianWorkspace work' + vim.cmd 'ObsidianNew' +end + +-- Function to create a new daily note +function M.new_daily_note() + vim.cmd 'ObsidianWorkspace daily' + vim.cmd 'ObsidianToday' +end + +-- Function to follow back Link +function M.followLink() + vim.cmd 'ObsidianFollowLink' +end + +-- Set up key mappings +function M.setup_keymaps() + vim.api.nvim_set_keymap( + 'n', + 'np', + 'lua require("obsidian_keymaps").new_personal_note()', + { noremap = true, silent = true, desc = 'New [P]ersonal note' } + ) + vim.api.nvim_set_keymap( + 'n', + 'nw', + 'lua require("obsidian_keymaps").new_work_note()', + { noremap = true, silent = true, desc = 'New [W]ork note' } + ) + vim.api.nvim_set_keymap( + 'n', + 'nd', + 'lua require("obsidian_keymaps").new_daily_note()', + { noremap = true, silent = true, desc = 'New [D]aily note' } + ) + vim.api.nvim_set_keymap('n', 'nf', 'lua require("obsidian_keymaps").followLink()', { noremap = true, silent = true, desc = '[F]ollow Link' }) +end + +return M