diff --git a/init.lua b/init.lua index aff5250e921..c214ac57069 100644 --- a/init.lua +++ b/init.lua @@ -99,8 +99,8 @@ do vim.g.maplocalleader = ' ' -- 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 + vim.g.python3_host_prog = vim.fn.exepath("python") -- [[ Setting options ]] -- See `:help vim.o` -- NOTE: You can change these options as you wish! @@ -110,7 +110,7 @@ do vim.o.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! - -- vim.o.relativenumber = true + vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = 'a' @@ -220,10 +220,10 @@ do 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 @@ -279,8 +279,142 @@ do -- In this section we set up some autocommands to run build -- steps for certain plugins after they are installed or updated. + vim.pack.add{ + { + src = "https://github.com/obsidian-nvim/obsidian.nvim", + version = vim.version.range "*", -- use latest release, remove to use latest commit + }, + } + require("obsidian").setup { + legacy_commands = false, -- this will be removed in 4.0.0 + workspaces = { + { + name = "personal", + path = "~/vaults/personal", + }, + { + name = "work", + path = "~/vaults/work", + }, + }, + } + + vim.pack.add{ + { src = "https://github.com/yousefhadder/markdown-plus.nvim" }, + } + require("markdown-plus").setup({ + enabled = true, + + features = { + list_management = true, + text_formatting = true, + thematic_break = true, + links = true, + images = true, + headers_toc = true, + quotes = true, + callouts = true, + code_block = true, + html_block_awareness = true, + table = true, + footnotes = true, + }, + + keymaps = { + enabled = true, + }, + + filetypes = { "markdown" }, + + toc = { + initial_depth = 2, + }, + + thematic_break = { + style = "---", -- "---" | "***" | "___" + }, + + callouts = { + default_type = "NOTE", + custom_types = {}, + }, + + code_block = { + enabled = true, + fence_style = "backtick", -- "backtick" | "tilde" + languages = { "lua", "python", "bash", "json", "yaml", "markdown", "rust" }, + }, + + table = { + enabled = true, + auto_format = true, + default_alignment = "left", + confirm_destructive = true, + width_mode = "literal", -- "literal" | "segment" set "segment" so cells + -- containing
don't inflate column width + wrap_break = "
", -- token used by wrap/break commands and the + -- cell-editor popup join + max_column_width = nil, -- integer ≥ 1 or nil width used by wrap-cell + -- and auto-wrap; nil prompts each time + auto_wrap = false, -- when true (and max_column_width is set), the + -- formatter auto-wraps cells exceeding the cap. + -- Per-table opt-out: place + -- on the line + -- immediately above the table + cell_editor = { -- floating popup for te + enabled = true, + border = "rounded", -- nvim_open_win border style + width = 0.6, -- fraction of editor width, (0, 1] + height = 0.4, -- fraction of editor height, (0, 1] + }, + keymaps = { + enabled = true, + prefix = "t", + insert_mode_navigation = true, + }, + }, + + footnotes = { + section_header = "Footnotes", + confirm_delete = true, + }, + + list = { + smart_outdent = true, + whitespace = "single", -- "single" | "shiftwidth" + -- "single" (default): one space after the marker (standard Markdown) + -- "shiftwidth": pad so content aligns to a whitespace_width column block (relative to the item's indent) + -- Note: formatters like Prettier enforce single-space and will override this on save. + whitespace_width = 4, -- integer ≥ 1; block width used when whitespace = "shiftwidth" + checkbox_completion = { + enabled = false, + format = "emoji", -- "emoji" | "comment" | "dataview" | "parenthetical" + date_format = "%Y-%m-%d", + remove_on_uncheck = true, + update_existing = true, + }, + }, + + links = { + smart_paste = { + enabled = false, + timeout = 5, -- 1..30 + }, + }, + }) + + vim.pack.add({ + { src = "https://github.com/folke/lazydev.nvim" }, + }) + + require('lazydev').setup({ + library = { + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }) local function run_build(name, cmd, cwd) - local result = vim.system(cmd, { cwd = cwd }):wait() + + local result = vim.system(cmd, { cwd = cwd }):wait() if result.code ~= 0 then local stderr = result.stderr or '' local stdout = result.stdout or '' @@ -375,8 +509,27 @@ do { 'gr', group = 'LSP Actions', mode = { 'n' } }, }, } + --create open buffers to switch through + --[b and ]b to move between open files + vim.pack.add { gh 'akinsho/bufferline.nvim'} + vim.opt.termguicolors = true + require('bufferline').setup { + tag= "*", + dependencies = 'nvim-tree/nvim-web-devicons', + } + + vim.pack.add({ + { src = 'https://github.com/nvim-lua/plenary.nvim' }, + { src = 'https://github.com/kdheepak/lazygit.nvim' }, + }) - -- [[ Colorscheme ]] + -- Optional appearance config (these are globals, not a setup call) + vim.g.lazygit_floating_window_scaling_factor = 0.9 + vim.g.lazygit_floating_window_winblend = 0 + + -- Keymap to open it + vim.keymap.set('n', 'lg', 'LazyGit', { desc = 'Open LazyGit' }) + -- [[ Colorscheme ]] -- You can easily change to a different colorscheme. -- Change the name of the colorscheme plugin below, and then -- change the command under that to load whatever the name of that colorscheme is. @@ -390,6 +543,32 @@ do }, } + vim.pack.add({ + { src = 'https://github.com/Isrothy/neominimap.nvim' }, + }) + + -- neominimap is configured via a global table, not a setup() call + vim.g.neominimap = { + auto_enable = true, + } + + vim.pack.add({ + { src = 'https://github.com/nvimdev/dashboard-nvim' }, + }) + + require('dashboard').setup({ + theme = 'hyper', + config = { + week_header = { enable = true }, + shortcut = { + { desc = '󰊳 Update', group = '@property', action = 'lua vim.pack.update()', key = 'u' }, + { icon = ' ', icon_hl = '@variable', desc = 'Files', group = 'Label', action = 'Telescope find_files', key = 'f' }, + { desc = ' Apps', group = 'DiagnosticHint', action = 'Telescope app', key = 'a' }, + { desc = ' dotfiles', group = 'Number', action = 'Telescope dotfiles', key = 'd' }, + }, + }, + }) + -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. @@ -588,6 +767,19 @@ end -- SECTION 6: LSP -- LSP keymaps, server configuration, Mason tools installations -- ============================================================ +-- +local function python_path() + -- venv (Windows: Scripts/python.exe) + if vim.env.VIRTUAL_ENV then + return vim.env.VIRTUAL_ENV .. '/Scripts/python.exe' + end + -- conda (Windows: python.exe lives in the env root, no Scripts) + if vim.env.CONDA_PREFIX then + return vim.env.CONDA_PREFIX .. '/python.exe' + end + return nil +end + do -- [[ LSP Configuration ]] -- Brief aside: **What is LSP?** @@ -615,7 +807,8 @@ do -- If you're wondering about lsp vs treesitter, you can check out the wonderfully -- and elegantly composed help section, `:help lsp-vs-treesitter` - -- Useful status updates for LSP. + + -- Useful status updates for LSP. vim.pack.add { gh 'j-hui/fidget.nvim' } require('fidget').setup {} @@ -694,7 +887,20 @@ do local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = { + settings = { + python = { + -- The venv fix: resolve packages from your activated venv. + -- Evaluated at startup, so activate the venv in PowerShell BEFORE launching nvim. + + pythonPath = python_path(), + }, + pyright = { + -- Let Ruff organize imports instead of Pyright (avoids the two fighting) + disableOrganizeImports = true, + }, + }, + }, -- rust_analyzer = {}, -- -- Some languages (like typescript) have entire language plugins that can be useful: @@ -703,6 +909,19 @@ do -- But for many setups, the LSP (`ts_ls`) will work just fine -- ts_ls = {}, + ruff = { + on_init = function(client) + client.server_capabilities.hoverProvider = false + end, + init_options = { + settings = { + lineLength = 88, + lint = { select = { 'E', 'F', 'I' } }, + }, + }, + }, + + stylua = {}, -- Used to format Lua code -- Special Lua Config, as recommended by neovim help docs @@ -747,9 +966,25 @@ do gh 'WhoIsSethDaniel/mason-tool-installer.nvim', } - -- Automatically install LSPs and related tools to stdpath for Neovim + -- Automatically install LSPs and related tools to stdpath for Neovim require('mason').setup {} + vim.pack.add({ + { src = "https://github.com/mrcjkb/rustaceanvim" }, + }) + + vim.g.rustaceanvim = { + server = { + on_attach = function(client, bufnr) + vim.keymap.set("n", "", function() + vim.cmd.RustLsp { 'hover', 'actions' } + end, { buffer = bufnr }) + vim.keymap.set("n", "a", function() + vim.cmd.RustLsp('codeAction') + end, { buffer = bufnr }) + end, + }, + } -- Ensure the servers and tools above are installed -- -- To check the current status of installed tools and/or manually install @@ -770,6 +1005,29 @@ do end end + vim.pack.add { + gh 'dstein64/nvim-scrollview', + } + + + require('scrollview').setup({ + excluded_filetypes = {'nerdtree'}, + current_only = true, + base = 'right', + column = 2, + signs_on_startup = {'all'}, + diagnostics_severities = {vim.diagnostic.severity.ERROR} + }) + + vim.api.nvim_create_autocmd({ 'BufWinEnter', 'BufEnter' }, { + callback = function() + vim.schedule(function() + pcall(vim.cmd.ScrollViewRefresh) + end) + end, + }) + + -- ============================================================ -- SECTION 7: FORMATTING -- conform.nvim setup and keymap @@ -783,7 +1041,7 @@ do -- You can specify filetypes to autoformat on save here: local enabled_filetypes = { -- lua = true, - -- python = true, + python = true, } if enabled_filetypes[vim.bo[bufnr].filetype] then return { timeout_ms = 500 } @@ -798,7 +1056,7 @@ do formatters_by_ft = { -- rust = { 'rustfmt' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { "ruff"}, -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true }, @@ -824,8 +1082,8 @@ do -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets -- - -- vim.pack.add { gh 'rafamadriz/friendly-snippets' } - -- require('luasnip.loaders.from_vscode').lazy_load() + vim.pack.add { gh 'rafamadriz/friendly-snippets' } + require('luasnip.loaders.from_vscode').lazy_load() -- [[ Autocomplete Engine ]] vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } } @@ -902,9 +1160,9 @@ do -- NOTE: You can also specify a branch or a specific commit vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } } - + require('nvim-treesitter.install').compilers = { 'zig' } -- Ensure basic parsers are installed - local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } + local parsers = {'zig', 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'python', "rust" } require('nvim-treesitter').install(parsers) ---@param buf integer @@ -966,12 +1224,12 @@ do -- 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 recommended 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 recommended keymaps -- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` --