diff --git a/.gitignore b/.gitignore index cd00aaf..5798b97 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ tags test.sh .luarc.json nvim -lazy-lock.json .DS_Store +.idea/ diff --git a/README.md b/README.md index 49fa0f3..b08978c 100755 --- a/README.md +++ b/README.md @@ -1,159 +1,36 @@ -# kickstart.nvim +# nvim -https://github.com/kdheepak/kickstart.nvim/assets/1813121/f3ff9a2b-c31f-44df-a4fa-8a0d7b17cf7b +My personal Neovim configuration — built for ML/AI and backend development. -### Introduction +Forked from [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) and evolved into something more opinionated. -A starting point for Neovim that is: - -* Small -* Single-file (with examples of moving to multi-file) -* Documented -* Modular - -This repo is meant to be used by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. - -Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. If you are experiencing issues, please make sure you have the latest versions. - -Distribution Alternatives: -- [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) - -### Installation - -> **NOTE** -> [Backup](#FAQ) your previous configuration (if any exists) - -Requirements: -* Make sure to review the readmes of the plugins if you are experiencing errors. In particular: - * [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers. -* See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native` - -Neovim's configurations are located under the following paths, depending on your OS: - -| OS | PATH | -| :- | :--- | -| Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| MacOS | `$XDG_CONFIG_HOME/nvim`, '~/.config/nvim` | -| Windows | `%userprofile%\AppData\Local\nvim\` | - -Clone kickstart.nvim: - -```sh -# on Linux and Mac -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim -# on Windows -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ +```bash +git clone https://git.jfraeys.com/jfraeysd/nvim.git ~/.config/nvim ``` -### Post Installation +## What's Inside -Run the following command and then **you are ready to go**! +**Core editing:** LSP via Mason, completion with nvim-cmp, Treesitter for syntax, autopairs, snippets -```sh +**Navigation:** Telescope for fuzzy finding, Harpoon for quick file jumps + +**Git:** Fugitive for operations, Gitsigns for inline blame/diff + +**Debug:** nvim-dap with Python/Go support + +**Aesthetics:** Custom theme setup with file tree and status line + +## Languages + +Python, Go, Rust, Lua, SQL, Bash — with LSP, linting, and formatting pre-configured. + +## Updates + +```bash +git -C ~/.config/nvim pull nvim --headless "+Lazy! sync" +qa ``` -### Recommended Steps - -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo (so that you have your own copy that you can modify) and then installing you can install to your machine using the methods above. - -> **NOTE** -> Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` - -### Configuration And Extension - -* Inside of your copy, feel free to modify any file you like! It's your copy! -* Feel free to change any of the default options in `init.lua` to better suit your needs. -* For adding plugins, there are 3 primary options: - * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` (uncomment the line importing the `custom/plugins` directory in the `init.lua` file to enable this) - * Modify `init.lua` with additional plugins. - * Include the `lua/kickstart/plugins/*` files in your configuration. - -You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration. - -#### Example: Adding an autopairs plugin - -In the file: `lua/custom/plugins/autopairs.lua`, add: - -```lua --- File: lua/custom/plugins/autopairs.lua - -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, -} -``` - - -This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). - -#### Example: Adding a file tree plugin - -In the file: `lua/custom/plugins/filetree.lua`, add: - -```lua --- Unless you are still migrating, remove the deprecated commands from v1.x -vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - -return { - "nvim-neo-tree/neo-tree.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - config = function () - require('neo-tree').setup {} - end, -} -``` - -This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. - -### Contribution - -Pull-requests are welcome. The goal of this repo is not to create a Neovim configuration framework, but to offer a starting template that shows, by example, available features in Neovim. Some things that will not be included: - -* Custom language server configuration (null-ls templates) -* Theming beyond a default colorscheme necessary for LSP highlight groups - -Each PR, especially those which increase the line count, should have a description as to why the PR is necessary. - -### FAQ - -* What should I do if I already have a pre-existing neovim configuration? - * You should back it up, then delete all files associated with it. - * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` - * You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide) -* What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information -* Are there any cool videos about this plugin? - * Current iteration of kickstart (coming soon) - * Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). Note the install via init.lua no longer works as specified. Please follow the install instructions in this file instead as they're up to date. - -### Windows Installation - -Installation may require installing build tools, and updating the run command for `telescope-fzf-native` - -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) - -This requires: - -- Install CMake, and the Microsoft C++ Build Tools on Windows - -```lua -{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } -``` +--- +Requires Neovim 0.10+, Git, and ripgrep. diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..ac2156e --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,79 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "CopilotChat.nvim": { "branch": "main", "commit": "69199d46b56f67a226789da256264c6291c4e63d" }, + "LuaSnip": { "branch": "master", "commit": "5a1e39223db9a0498024a77b8441169d260c8c25" }, + "atac.nvim": { "branch": "main", "commit": "31a23a02fb2bc8c85b0b572d05aa6cb09debb8e4" }, + "auto-dark-mode.nvim": { "branch": "master", "commit": "e300259ec777a40b4b9e3c8e6ade203e78d15881" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-git": { "branch": "main", "commit": "b24309c386c9666c549a1abaedd4956541676d06" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "c2526f1cde528a66e086ab1668e996d162c75f4f" }, + "copilot.lua": { "branch": "master", "commit": "3faffefbd6ddeb52578535ec6b730e0b72d7fd1a" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "fidget.nvim": { "branch": "main", "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, + "gitsigns.nvim": { "branch": "main", "commit": "1ce96a464fdbc24208e24c117e2021794259005d" }, + "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, + "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "jupytext.vim": { "branch": "master", "commit": "f15aff4515eb6a09afa0d7f41eb23be53c1e2e14" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lsp_signature.nvim": { "branch": "master", "commit": "0efb088dce050d38a3608ee69f80f2a62cf9849c" }, + "lspkind-nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "marks.nvim": { "branch": "master", "commit": "f353e8c08c50f39e99a9ed474172df7eddd89b72" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ae609525ddf01c153c39305730b1791800ffe4fe" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "neogen": { "branch": "main", "commit": "23e7e9f883d01289ebd90e98025acc860ea26366" }, + "neotest": { "branch": "master", "commit": "deadfb1af5ce458742671ad3a013acb9a6b41178" }, + "neotest-gtest": { "branch": "main", "commit": "b66f1d33cbf3b37b9803e6bc7ef47ac60eba86b1" }, + "neotest-python": { "branch": "master", "commit": "b0d3a861bd85689d8ed73f0590c47963a7eb1bf9" }, + "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-coverage": { "branch": "main", "commit": "a939e425e363319d952a6c35fb3f38b34041ded2" }, + "nvim-dap": { "branch": "master", "commit": "e47878dcf1ccc30136b30d19ab19fe76946d61cd" }, + "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, + "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-lint": { "branch": "master", "commit": "bcd1a44edbea8cd473af7e7582d3f7ffc60d8e81" }, + "nvim-lspconfig": { "branch": "master", "commit": "66fd02ad1c7ea31616d3ca678fa04e6d0b360824" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-context": { "branch": "master", "commit": "64dd4cf3f6fd0ab17622c5ce15c91fc539c3f24a" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "a0e182ae21fda68c59d1f36c9ed45600aef50311" }, + "nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" }, + "oil.nvim": { "branch": "master", "commit": "f55b25e493a7df76371cfadd0ded5004cb9cd48a" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "refactoring.nvim": { "branch": "master", "commit": "6784b54587e6d8a6b9ea199318512170ffb9e418" }, + "render-markdown.nvim": { "branch": "main", "commit": "48b4175dbca8439d30c1f52231cbe5a712c8f9d9" }, + "schemastore.nvim": { "branch": "main", "commit": "ff73799fc8df725d51eada87a113581ba4d3717b" }, + "solarized.nvim": { "branch": "master", "commit": "fe02ed49cc017cc93657bd6306a2624394611c69" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope-undo.nvim": { "branch": "main", "commit": "928d0c2dc9606e01e2cc547196f48d2eaecf58e5" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "trouble.nvim": { "branch": "main", "commit": "748ca2789044607f19786b1d837044544c55e80a" }, + "undotree": { "branch": "master", "commit": "fc28931fbfba66ab75d9af23fe46ffbbb9de6e8c" }, + "venv-selector.nvim": { "branch": "main", "commit": "26a6da0348dc2d0a3787e095bd4e68d976304bb2" }, + "vim-dadbod": { "branch": "master", "commit": "6d1d41da4873a445c5605f2005ad2c68c99d8770" }, + "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" }, + "vim-dadbod-ui": { "branch": "master", "commit": "48c4f271da13d380592f4907e2d1d5558044e4e5" }, + "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, + "vim-rhubarb": { "branch": "master", "commit": "5496d7c94581c4c9ad7430357449bb57fc59f501" }, + "vim-slime": { "branch": "main", "commit": "2792879461d3f562a3a353f83ed0dc5dc3f5bb82" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vimtex": { "branch": "master", "commit": "f707368022cdb851716be0d2970b90599c84a6a6" }, + "wezterm.nvim": { "branch": "main", "commit": "032c33b621b96cc7228955b4352b48141c482098" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }, + "zen-mode.nvim": { "branch": "main", "commit": "8564ce6d29ec7554eb9df578efa882d33b3c23a7" } +} diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 36211f2..64df1a1 100755 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -1,67 +1,91 @@ --- Auto-format on save -vim.cmd([[ - augroup FormatOnSave - autocmd! - autocmd BufWritePre * lua vim.lsp.buf.format({ async = false }) - augroup END -]]) - --- Augroup for Highlight on yank -vim.cmd([[ - augroup YankHighlight - autocmd! - autocmd TextYankPost * lua vim.hl.on_yank() - augroup END -]]) - --- Remove trailing whitespace -vim.cmd([[ - augroup RemoveTrailingWhitespace - autocmd! - autocmd BufWritePre * %s/\s\+$//e - augroup END -]]) - --- Append newline at EOF, excluding YAML files -vim.cmd([[ - augroup append_newline_at_eof - autocmd! - autocmd BufWritePre * silent! if !empty(getline('$')) && getline('$') !~# '\n$' && &filetype != 'yaml' | call append(line('$'), '') | endif - augroup END -]]) - local function augroup(name) - return vim.api.nvim_create_augroup('lazyvim_' .. name, { clear = true }) + return vim.api.nvim_create_augroup('nvim_' .. name, { clear = true }) end +-- Auto-format on save +vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup('format_on_save'), + pattern = '*', + callback = function() + vim.lsp.buf.format({ async = false }) + end, + desc = 'Auto-format on save with LSP', +}) + +-- Highlight on yank +vim.api.nvim_create_autocmd('TextYankPost', { + group = augroup('highlight_yank'), + callback = function() + vim.hl.on_yank() + end, + desc = 'Highlight yanked text', +}) + +-- Remove trailing whitespace +vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup('remove_trailing_whitespace'), + pattern = '*', + command = [[%s/\s\+$//e]], + desc = 'Remove trailing whitespace on save', +}) + +-- Append newline at EOF (excluding YAML) +vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup('append_newline_eof'), + pattern = '*', + callback = function() + local last_line = vim.fn.getline('$') + local ft = vim.bo.filetype + if last_line ~= '' and not last_line:match('\n$') and ft ~= 'yaml' then + vim.fn.append(vim.fn.line('$'), '') + end + end, + desc = 'Append newline at EOF (except YAML)', +}) + +-- Auto-update plugins on startup vim.api.nvim_create_autocmd('VimEnter', { group = augroup('autoupdate'), callback = function() - if require('lazy.status').has_updates() then + local ok, lazy_status = pcall(require, 'lazy.status') + if ok and lazy_status.has_updates() then require('lazy').update({ show = false }) end end, + desc = 'Auto-update plugins on startup', }) +-- Sync plugins after lazy check vim.api.nvim_create_autocmd('User', { pattern = 'LazyCheck', - -- pattern = "LazyVimStarted", - desc = 'Update lazy.nvim plugins', + group = augroup('lazy_sync'), callback = function() vim.schedule(function() require('lazy').sync({ wait = false, show = false }) end) end, + desc = 'Sync plugins after LazyCheck', }) +-- Terminal buffer settings vim.api.nvim_create_autocmd('TermOpen', { + group = augroup('terminal_settings'), pattern = '*', - group = vim.api.nvim_create_augroup('custom-term-open', { clear = true }), - desc = 'Automatically start insert mode in terminal buffers', callback = function() vim.cmd('startinsert') - vim.cmd('setlocal nonumber norelativenumber') + vim.wo.number = false + vim.wo.relativenumber = false vim.cmd('normal! G') - vim.cmd('tnoremap ') end, + desc = 'Terminal buffer auto-insert and no line numbers', +}) + +-- Terminal mode escape mapping (applied per buffer) +vim.api.nvim_create_autocmd('TermOpen', { + group = augroup('terminal_escape'), + pattern = '*', + callback = function() + vim.keymap.set('t', '', '', { buffer = true, desc = 'Exit terminal mode' }) + end, + desc = 'Terminal escape mapping', }) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index 3a2d428..5e0dfe0 100755 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -39,35 +39,18 @@ vim.keymap.set('n', '[q', 'lprevzz', { desc = 'Location List Prev' }) vim.keymap.set('n', 'bn', 'bnextzz', { desc = 'Quick Nav Buf Next' }) vim.keymap.set('n', 'bp', 'bprevzz', { desc = 'Quick Nav Buf Prev' }) vim.keymap.set('n', 'bd', 'bdelete', { desc = 'Quick Nav Buf Delete' }) -vim.keymap.set('n', 'bs', 'split', { desc = 'Openn Buf Horizontal Split' }) +vim.keymap.set('n', 'bs', 'split', { desc = 'Open Buf Horizontal Split' }) vim.keymap.set('n', 'bv', 'vsp', { desc = 'Open Buf Vertical Split' }) --- vim.keymap.set('n', 'bt', function() --- vim.cmd.vnew() --- vim.cmd.term() --- vim.cmd.wincmd('J') --- vim.api.nvim_win_set_height(0, 15) --- end, { desc = 'Open Buf in Terminal' }) - --- -- open terminal for R and Python --- vim.keymap.set('n', 'bR', 'terminal R', { desc = 'Open R Terminal' }) --- vim.keymap.set('n', 'bP', 'terminal python', { desc = 'Open Python Terminal' }) -- Editing Keymaps vim.keymap.set('x', 'p', [["_dP"]], { desc = 'Paste without register' }) vim.keymap.set({ 'n', 'v' }, 'D', [["_d"]], { desc = 'Delete without register' }) vim.keymap.set({ 'n', 'v' }, 'y', '"+y', { desc = 'Copy to + register' }) vim.keymap.set('n', 'Y', '"+Y') --- replace current word in current scope -vim.keymap.set( - 'n', - 'rw', - ':%s/\\<\\>//gI', - { desc = '[R]eplace Current [W]ord in Current Scope' } -) -- replace current word in file scope vim.keymap.set( 'n', - 'rW', + 'rw', ':%s/\\<\\>//gI', { desc = '[R]eplace Current [W]ord in File Scope' } ) @@ -130,33 +113,3 @@ vim.keymap.set('n', 'fp', function() cwd = vim.fs.joinpath(vim.fn.stdpath('data'), 'lazy'), }) end, { desc = '[F]ind [P]lugin Files' }) - --- local runner = require("quarto.runner") --- vim.keymap.set('n', 'qrc', runner.run_cell, { desc = '[R]un [C]ell', silent = true }) --- vim.keymap.set('n', 'qra', runner.run_above, { desc = '[R]un cell and [A]bove', silent = true }) --- vim.keymap.set('n', "qrA", runner.run_all, { desc = "run all cells", silent = true }) --- vim.keymap.set('n', "qrl", runner.run_line, { desc = "run line", silent = true }) --- vim.keymap.set('v', 'qr', runner.run_range, { desc = "run visual range", silent = true }) --- vim.keymap.set('n', 'qRA', function() --- runner.run_all(true) --- end, { desc = "run all cells of all languages", silent = true }) - --- Refactoring Keymaps --- vim.keymap.set({ "x" }, "re", [[lua require('refactoring').refactor('Extract Function')]], --- { noremap = true, silent = true, expr = false, desc = "Extract Function" }) --- vim.keymap.set( --- { "x" }, --- "rf", [[lua require('refactoring').refactor('Extract Function To File')]], --- { noremap = true, silent = true, expr = false, desc = "Extract Function To File" } ---) --- vim.keymap.set({ "x" }, "rv", [[lua require('refactoring').refactor('Extract Variable')]], --- { noremap = true, silent = true, expr = false, desc = "Extract Variable" }) --- vim.keymap.set({ "n" }, "rI", [[lua require('refactoring').refactor('Inline Variable')]], --- { noremap = true, silent = true, expr = false, desc = "Inline Variable" }) --- vim.keymap.set({ "n", "x" }, "ri", [[lua require('refactoring').refactor('Inline Variable')]], --- { noremap = true, silent = true, expr = false, desc = "Inline Variable" }) --- --- vim.keymap.set({ "n" }, "rb", [[lua require('refactoring').refactor('Extract Block')]], --- { noremap = true, silent = true, expr = false, desc = "Extract Block" }) --- vim.keymap.set({ "n" }, "rbf", [[lua require('refactoring').refactor('Extract Block To File')]], --- { noremap = true, silent = true, expr = false, desc = "Extract Block To File" }) diff --git a/lua/config/themes.lua b/lua/config/themes.lua deleted file mode 100755 index e69de29..0000000 diff --git a/lua/config/utils.lua b/lua/config/utils.lua index 8203d27..8f274e1 100755 --- a/lua/config/utils.lua +++ b/lua/config/utils.lua @@ -1,18 +1,17 @@ --- Function to get the current visual selection +---Get the current visual selection +---@return string The selected text or empty string if no selection local function get_visual_selection() vim.cmd('noau normal! "vy"') local text = vim.fn.getreg('v') - -- optional: clear register v - -- vim.fn.setreg('v', '') - text = text:gsub('\n$', '') -- remove trailing newline return text end --- Function to get the current search query +---Get the search query (visual selection or word under cursor) +---@return string The query to search for local function get_search_query() local word_under_cursor = vim.fn.expand('') - local visual_selection = get_visual_selection() -- call local function directly + local visual_selection = get_visual_selection() return visual_selection ~= '' and visual_selection or word_under_cursor end diff --git a/lua/custom/plugins/comments.lua b/lua/custom/plugins/comments.lua deleted file mode 100755 index c086553..0000000 --- a/lua/custom/plugins/comments.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'numToStr/Comment.nvim', - opts = {}, -} diff --git a/lua/custom/plugins/lsp-config.lua b/lua/custom/plugins/lsp-config.lua index 5494a9c..4745b49 100755 --- a/lua/custom/plugins/lsp-config.lua +++ b/lua/custom/plugins/lsp-config.lua @@ -14,36 +14,6 @@ return { { 'j-hui/fidget.nvim', opts = {}, event = 'LspAttach' }, { 'ray-x/lsp_signature.nvim', event = 'LspAttach' }, - -- Treesitter - { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - event = 'BufReadPost', - opts = { - highlight = { enable = true }, - indent = { enable = true }, - ensure_installed = { - 'bash', - 'c', - 'cpp', - 'go', - 'html', - 'julia', - 'lua', - 'markdown', - 'python', - 'rust', - 'sql', - 'vim', - 'vimdoc', - 'yaml', - 'zig', - }, - }, - config = true, - }, - { 'nvim-treesitter/nvim-treesitter-textobjects', event = 'BufReadPost' }, - -- Python venv selector { 'linux-cultist/venv-selector.nvim', diff --git a/lua/custom/plugins/lsp-servers.lua b/lua/custom/plugins/lsp-servers.lua new file mode 100644 index 0000000..083779b --- /dev/null +++ b/lua/custom/plugins/lsp-servers.lua @@ -0,0 +1,301 @@ +local M = {} + +---Check if path exists +---@param p string|nil +---@return boolean +local function path_exists(p) + return p and p ~= '' and vim.uv.fs_stat(p) ~= nil +end + +---Get Mason binary path +---@param name string +---@return string +local function mason_bin(name) + local p = vim.fs.joinpath(vim.fn.stdpath('data'), 'mason', 'bin', name) + if path_exists(p) then + return p + end + return name +endx + +---Find Julia binary +---@return string +local function julia_bin() + local home = vim.env.HOME or '' + local candidates = { + vim.fn.exepath('julia'), + vim.fs.joinpath(home, '.juliaup', 'bin', 'julia'), + '/opt/homebrew/bin/julia', + '/usr/local/bin/julia', + } + for _, p in ipairs(candidates) do + if path_exists(p) then + return p + end + end + return 'julia' +end + +local julia_cmd = julia_bin() +local julia_ls_project = vim.fn.expand('~/.julia/environments/nvim-lsp') + +-- Servers that should provide formatting +M.format_enabled_servers = { + bashls = true, + clangd = true, + gopls = true, + html = true, + htmx = true, + jsonls = true, + lua_ls = true, + marksman = true, + pyright = true, + ruff = true, + rust_analyzer = true, + taplo = true, + texlab = true, + yamlls = true, + zls = true, +} + +-- Server-specific configurations +M.servers = { + bashls = { + filetypes = { 'sh', 'bash', 'zsh' }, + }, + + html = { + filetypes = { 'html', 'htmldjango' }, + init_options = { + configurationSection = { 'html', 'css', 'javascript' }, + embeddedLanguages = { + css = true, + javascript = true, + }, + }, + }, + + htmx = { + cmd = { 'htmx-lsp' }, + filetypes = { 'html', 'htmx' }, + }, + + gopls = { + settings = { + gopls = { + gofumpt = true, + staticcheck = true, + completeUnimported = true, + usePlaceholders = true, + analyses = { unusedparams = true }, + }, + }, + }, + + clangd = { + cmd = { + 'clangd', + '--background-index', + '--clang-tidy', + '--header-insertion=iwyu', + '--completion-style=detailed', + '--header-insertion-decorators', + '--query-driver=/usr/bin/clang,/usr/bin/clang++', + '--enable-config', + }, + settings = { + formatting = true, + inlayHints = { + designators = true, + enabled = true, + parameterNames = true, + deducedTypes = true, + }, + }, + filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'h', 'hpp', 'hxx' }, + }, + + marksman = { + filetypes = { 'markdown' }, + settings = { + marksman = { + extensions = { 'mdx' }, + }, + }, + }, + + jsonls = { + cmd = { 'vscode-json-language-server', '--stdio' }, + settings = { + json = { + validate = { enable = true }, + }, + }, + }, + + julials = { + filetypes = { 'julia' }, + cmd = { + julia_cmd, + '--project=' .. julia_ls_project, + '--startup-file=no', + '--history-file=no', + '-e', + [[ + using Logging + using LanguageServer + using SymbolServer + + global_logger(ConsoleLogger(stderr, Logging.Warn)) + + function project_path() + try + return LanguageServer.find_project_path(pwd()) + catch + return pwd() + end + end + + depot_path = get(ENV, "JULIA_DEPOT_PATH", "") + + server = LanguageServer.LanguageServerInstance( + stdin, + stdout, + something(project_path(), pwd()), + depot_path, + ) + + server.runlinter = true + run(server) + ]], + }, + settings = { + julia = { + lint = { + run = true, + }, + }, + }, + }, + + pyright = { + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'workspace', + useLibraryCodeForTypes = true, + typeCheckingMode = 'none', + reportGeneralTypeIssues = false, + }, + }, + }, + }, + + ruff = { + filetypes = { 'python' }, + on_init = function() + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.name == 'ruff' then + client.server_capabilities.hoverProvider = false + end + end, + desc = 'LSP: Disable hover capability from Ruff', + }) + end, + }, + + rust_analyzer = { + settings = { + ['rust-analyzer'] = { + imports = { granularity = { group = 'module' }, prefix = 'self' }, + cargo = { buildScripts = { enable = true } }, + procMacro = { enable = true }, + checkOnSave = { command = 'clippy' }, + }, + }, + }, + + taplo = { + filetypes = { 'toml' }, + }, + + yamlls = { + settings = { + yaml = { + schemaStore = { enable = true }, + validate = true, + }, + }, + }, + + texlab = { + filetypes = { 'tex', 'plaintex', 'bib', 'cls', 'sty' }, + settings = { + texlab = { + build = { + onSave = false, + }, + diagnostics = { + ignoredPatterns = { + '^Overfull \\hbox', + '^Underfull \\hbox', + '^Package.*Warning', + }, + }, + auxDirectory = 'output', + }, + }, + }, + + lua_ls = { + cmd = { mason_bin('lua-language-server') }, + settings = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + diagnostics = { globals = { 'vim' } }, + }, + }, + }, + + sqls = { + filetypes = { 'sql', 'mysql', 'plsql', 'postgresql' }, + settings = { + sql = { + connections = { + { + driver = 'sqlite3', + dataSourceName = 'file::memory:?cache=shared', + }, + }, + }, + }, + on_init = function(client) + local root_dir = client.config.root_dir or vim.fn.getcwd() + local db_files = vim.fn.globpath(root_dir, '*.db', false, true) + vim.list_extend(db_files, vim.fn.globpath(root_dir, '*.sqlite', false, true)) + + if #db_files > 0 then + local connections = {} + for _, path in ipairs(db_files) do + table.insert(connections, { + driver = 'sqlite3', + dataSourceName = vim.fn.fnamemodify(path, ':p'), + }) + end + client.config.settings.sql.connections = connections + client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }) + end + end, + }, + + zls = { + filetypes = { 'zig' }, + }, +} + +return M