diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua new file mode 100644 index 00000000..481f90a3 --- /dev/null +++ b/after/ftplugin/markdown.lua @@ -0,0 +1 @@ +vim.opt_local.wrap = true diff --git a/after/ftplugin/rust.lua b/after/ftplugin/rust.lua new file mode 100644 index 00000000..b02de1da --- /dev/null +++ b/after/ftplugin/rust.lua @@ -0,0 +1,10 @@ +local bufnr = vim.api.nvim_get_current_buf() +vim.keymap.set( + "n", + "a", + function() + vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping + -- or vim.lsp.buf.codeAction() if you don't want grouping. + end, + { desc = "Rust LSP Code [Action]", silent = true, buffer = bufnr } +) diff --git a/after/ftplugin/typst.lua b/after/ftplugin/typst.lua new file mode 100644 index 00000000..481f90a3 --- /dev/null +++ b/after/ftplugin/typst.lua @@ -0,0 +1 @@ +vim.opt_local.wrap = true diff --git a/init.lua b/init.lua index db55a9e8..b821da9a 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -320,6 +320,9 @@ require('lazy').setup({ -- Useful for getting pretty icons, but requires a Nerd Font. { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + + --- Get undo history for telescope + 'debugloop/telescope-undo.nvim', }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -363,6 +366,7 @@ require('lazy').setup({ -- Enable Telescope extensions if they are installed pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') + pcall(require('telescope').load_extension, 'undo') -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' @@ -540,7 +544,8 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = {}, + ruff_lsp = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -565,6 +570,10 @@ require('lazy').setup({ }, }, }, + yamlls = { yaml = {} }, + typst_lsp = { { filetypes = { 'typst' } } }, + jsonls = { { filetypes = { 'json' } } }, + taplo = { filetypes = { 'toml' } }, } -- Ensure the servers and tools above are installed @@ -593,6 +602,8 @@ require('lazy').setup({ server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, + -- rust_analyzer is set up by rustacevim + ['rust_analyzer'] = function() end, }, } end, @@ -644,12 +655,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -728,22 +739,18 @@ require('lazy').setup({ } end, }, - { -- You can easily change to a different colorscheme. -- Change the name of the colorscheme plugin below, and then -- change the command in the config to whatever the name of that colorscheme is. -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. + 'ellisonleao/gruvbox.nvim', + priority = 1000, init = function() - -- 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'. - vim.cmd.colorscheme 'tokyonight-night' - - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' + require('gruvbox').setup { + overrides = { SignColumn = { bg = '' } }, + } + vim.o.background = 'dark' + vim.cmd.colorscheme 'gruvbox' end, }, @@ -791,7 +798,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'html', 'json', 'lua', 'luadoc', 'markdown', 'python', 'rust', 'toml', 'typst', 'vim', 'vimdoc', 'yaml' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -827,16 +834,16 @@ 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.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', -- 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' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the @@ -859,5 +866,9 @@ require('lazy').setup({ }, }) +-- Import custom settings +require 'custom.init' +require 'custom.keymap' + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 00000000..9170c9ca --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1,19 @@ +-- Fold code by expression +vim.opt.foldenable = false +vim.opt.foldmethod = 'expr' +vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + +-- Turn off line wrapping +vim.opt.wrap = false + +-- Typst filetype support +vim.filetype.add { extension = { typ = 'typst' } } + +-- Reset the cursor after leaving vim. Without this, the cursor changes to a +-- block for the terminal. +vim.cmd [[ + augroup RestoreCursorShapeOnExit + autocmd! + autocmd VimLeave * set guicursor=a:ver1 + augroup END +]] diff --git a/lua/custom/keymap.lua b/lua/custom/keymap.lua new file mode 100644 index 00000000..ab9fed3b --- /dev/null +++ b/lua/custom/keymap.lua @@ -0,0 +1,25 @@ +-- Custom keychains +require('which-key').register { + ['p'] = { name = '[P]ython', _ = 'which_key_ignore' }, +} +-- Undo +vim.keymap.set("n", "su", require("telescope").extensions.undo.undo, { desc = '[S]earch [U]ndo' }) + +-- Lazygit +vim.keymap.set("n", "gg", ":LazyGit", { desc = "[G]it Lazy[G]it" }) + +-- Debug +vim.keymap.set({ "n", "v" }, "pm", function() require("dap-python").test_method() end, + { desc = '[P]ython Debug [M]ethod' }) +vim.keymap.set({ "n", "v" }, "pc", function() require("dap-python").test_class() end, + { desc = '[P]ython Debug [C]lass' }) +vim.keymap.set("v", "k", function() require("dapui").eval() end, { desc = "Debug: Eval" }) + +-- Navigate buffers +vim.keymap.set("n", "l", ":ls:b", { desc = "Select buffer" }) + +-- Make +vim.keymap.set("n", "m", ":make ", { desc = "[M]ake" }) + +-- Telescope undo +vim.keymap.set("n", "su", require("telescope").extensions.undo.undo, { desc = '[S]earch [U]ndo' }) diff --git a/lua/custom/lazygit.lua b/lua/custom/lazygit.lua new file mode 100644 index 00000000..84fd5478 --- /dev/null +++ b/lua/custom/lazygit.lua @@ -0,0 +1,7 @@ +return { + "kdheepak/lazygit.nvim", + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + } +} diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..4a1b801d --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,15 @@ +return { + "windwp/nvim-autopairs", + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require("nvim-autopairs").setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) + end, +} diff --git a/lua/custom/plugins/neo-tree.lua b/lua/custom/plugins/neo-tree.lua new file mode 100644 index 00000000..96113aed --- /dev/null +++ b/lua/custom/plugins/neo-tree.lua @@ -0,0 +1,11 @@ +return { + --- File explorer + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + } +} diff --git a/lua/custom/plugins/rustaceanvim.lua b/lua/custom/plugins/rustaceanvim.lua new file mode 100644 index 00000000..68f66000 --- /dev/null +++ b/lua/custom/plugins/rustaceanvim.lua @@ -0,0 +1,5 @@ +return { + 'mrcjkb/rustaceanvim', + version = '^4', -- Recommended + ft = { 'rust' }, +} diff --git a/lua/custom/plugins/typst_lsp.lua b/lua/custom/plugins/typst_lsp.lua new file mode 100644 index 00000000..ac502ad5 --- /dev/null +++ b/lua/custom/plugins/typst_lsp.lua @@ -0,0 +1,6 @@ +return { require 'lspconfig'.typst_lsp.setup { + settings = { + exportPdf = "never" -- Choose onType, onSave or never. + -- serverPath = "" -- Normally, there is no need to uncomment it. + } +} } diff --git a/lua/custom/plugins/vim-tmux-navigator.lua b/lua/custom/plugins/vim-tmux-navigator.lua new file mode 100644 index 00000000..8576a858 --- /dev/null +++ b/lua/custom/plugins/vim-tmux-navigator.lua @@ -0,0 +1,9 @@ +return { + -- Seamless navigation between tmux panes and vim splits + 'christoomey/vim-tmux-navigator', + config = function() + -- disable netrw for nvim-tree + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + end, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 7be4abdb..3b7013db 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -22,7 +22,8 @@ return { 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here - 'leoluz/nvim-dap-go', + -- 'leoluz/nvim-dap-go', + 'mfussenegger/nvim-dap-python', }, config = function() local dap = require 'dap' @@ -41,7 +42,8 @@ return { -- online, please don't ask me how to install them :) ensure_installed = { -- Update this to ensure that you have the debuggers for the langs you want - 'delve', + -- 'delve', + 'debugpy', }, } @@ -85,6 +87,7 @@ return { dap.listeners.before.event_exited['dapui_config'] = dapui.close -- Install golang specific config - require('dap-go').setup() + -- require('dap-go').setup() + require('dap-python').setup('~/.local/share/nvim/mason/packages/debugpy/venv/bin/python') end, }