diff --git a/init.lua b/init.lua index 91b8532..8c91b56 100644 --- a/init.lua +++ b/init.lua @@ -102,10 +102,10 @@ vim.g.have_nerd_font = false -- For more options, you can see `:help option-list` -- Make line numbers default --- vim.opt.number = true +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 = false -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -173,17 +173,22 @@ vim.bo.softtabstop = 2 -- case insensitive searching UNLESS /C or capital in searching vim.opt.ignorecase = true +-- (Exuberant/Universal) Ctags +vim.opt.tags = 'tags' +vim.keymap.set("n", "ct", function() + vim.cmd("!ctags -f tags -R --exclude=build --exclude=build-sim --exclude=node_modules --exclude=.git .") + print("ctags regenerated") +end, { desc = "Regenerate ctags", silent = true }) + -- Set highlight on search, but clear on pressing in normal mode vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') -vim.keymap.set('n', 'e', vim.cmd.Ex) +-- Go next and previous in quickfix list +vim.keymap.set('n', 'cn', 'cnext') +vim.keymap.set('n', 'cp', 'cprev') --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'd', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) -vim.keymap.set('n', 'la', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +vim.keymap.set('n', 'e', vim.cmd.Ex) -- greatest remap ever -- doesn't remove from copy buffer on past vim.keymap.set('x', 'p', [["_dP]]) @@ -205,10 +210,10 @@ end, {}) 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 @@ -258,7 +263,7 @@ vim.opt.rtp:prepend(lazypath) -- NOTE: Here is where you install your plugins. require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - -- 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -332,108 +337,18 @@ require('lazy').setup({ -- -- Use the `dependencies` key to specify the dependencies of a particular plugin - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, + -- Fuzzy Finder (files, lsp, etc) + { + "ibhagwan/fzf-lua", + -- optional for icon support + dependencies = { "nvim-tree/nvim-web-devicons" }, + -- or if using mini.icons/mini.nvim + -- dependencies = { "echasnovski/mini.icons" }, + opts = {}, config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- 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 { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) + require('fzf-lua').setup({}) + vim.keymap.set("n", "f", "FzfLua files") + vim.keymap.set("n", "g", "FzfLua live_grep") end, }, @@ -498,30 +413,32 @@ require('lazy').setup({ vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- 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 . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + -- Go to definition (default should also work if 'tagfunc' is set) + map('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + -- Find references and open in quickfix list + map('gr', function() + vim.lsp.buf.references() + vim.cmd('copen') + end, '[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('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + -- Go to implementation + map('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - -- 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('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + -- Go to type definition + map('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + -- Document symbols in quickfix list + map('ds', function() + vim.lsp.buf.document_symbol() + vim.cmd('copen') + end, '[D]ocument [S]ymbols') - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- Workspace symbols in quickfix list + map('ws', function() + vim.lsp.buf.workspace_symbol() + vim.cmd('copen') + end, '[W]orkspace [S]ymbols') -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. @@ -542,9 +459,15 @@ require('lazy').setup({ -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - map('lg', vim.diagnostic.open_float, 'Open diagnostics') map('lf', vim.lsp.buf.format, '[L]sp [F]ormat') + -- Diagnostic keymaps + map('d', vim.diagnostic.open_float, 'Open diagnostics') + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) + vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) + vim.keymap.set('n', 'd', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) + vim.keymap.set('n', 'da', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + -- The following two autocommands are used to highlight references of the -- word under your cursor when your cursor rests there for a little while. -- See `:help CursorHold` for information about when this is executed @@ -570,9 +493,9 @@ require('lazy').setup({ -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + -- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - vim.filetype.add({ extension = { templ = "templ" } }) + -- vim.filetype.add({ extension = { templ = "templ" } }) -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. @@ -589,15 +512,15 @@ require('lazy').setup({ -- cmd = { '/home/talksik/Qt/6.6.1/gcc_64/bin/qmlls' }, -- filetypes = { 'qml' }, -- }, - clangd = { - cmd = { - '/Users/talksik/Qt/Qt Creator.app/Contents/Resources/libexec/clang/bin/clangd', - '--offset-encoding=utf-16', - -- -- Need below if you want to use an embedded sysroot for library & header files - -- -- '--query-driver=/home/talksik-desktop/Qt/6.6.2/Boot2Qt/raspberrypi4-64/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-*', - }, - filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'hpp', 'h', 'cc' }, - }, + -- clangd = { + -- cmd = { + -- '/Users/talksik/Qt/Qt Creator.app/Contents/Resources/libexec/clang/bin/clangd', + -- '--offset-encoding=utf-16', + -- -- -- Need below if you want to use an embedded sysroot for library & header files + -- -- -- '--query-driver=/home/talksik-desktop/Qt/6.6.2/Boot2Qt/raspberrypi4-64/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-*', + -- }, + -- filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'hpp', 'h', 'cc' }, + -- }, -- gopls = {}, templ = { cmd = { 'templ', 'lsp' }, @@ -679,161 +602,6 @@ require('lazy').setup({ end, }, - { -- Autoformat - 'stevearc/conform.nvim', - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = false, cpp = false } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } - end, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - javascript = { { "prettierd", "prettier" } }, - typescript = { { "prettierd", "prettier" } }, - }, - }, - config = function() - -- https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#command-to-toggle-format-on-save - vim.api.nvim_create_user_command('FormatDisable', function(args) - if args.bang then - -- FormatDisable! will disable formatting just for this buffer - vim.b.disable_autoformat = true - else - vim.g.disable_autoformat = true - end - end, { - desc = 'Disable autoformat-on-save', - bang = true, - }) - vim.api.nvim_create_user_command('FormatEnable', function() - vim.b.disable_autoformat = false - vim.g.disable_autoformat = false - end, { - desc = 'Re-enable autoformat-on-save', - }) - end, - }, - - { -- Autocompletion - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - -- `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, - -- }, - }, - }, - 'saadparwaiz1/cmp_luasnip', - - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', - }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), - - -- Scroll the documentation window [b]ack / [f]orward - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, - -- accept with enter - -- disabled because weird UX in insert mode (next line vs. confirm) - -- [''] = cmp.mapping.confirm { select = true }, - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [''] = cmp.mapping.complete {}, - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, - } - 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. @@ -855,45 +623,6 @@ require('lazy').setup({ -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - { - "folke/noice.nvim", - event = "VeryLazy", - opts = { - -- add any options here - }, - dependencies = { - -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries - "MunifTanjim/nui.nvim", - -- OPTIONAL: - -- `nvim-notify` is only needed, if you want to use the notification view. - -- If not available, we use `mini` as the fallback - -- "rcarriga/nvim-notify", - } - }, - - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [']quote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - -- NOTE: disabled because conflicts with basic `s` command - -- require('mini.surround').setup() - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 46b3497..245d5ce 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -3,28 +3,8 @@ -- -- See the kickstart.nvim README for more information return { - { - 'nvim-treesitter/nvim-treesitter-context', - config = function() - require('treesitter-context').setup { - enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) - max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. - min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. - line_numbers = true, - multiline_threshold = 20, -- Maximum number of lines to show for a single context - trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' - mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' - -- Separator between context and content. Should be a single character string, like '-'. - -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. - separator = nil, - zindex = 20, -- The Z-index of the context window - on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching - } - end, - }, 'github/copilot.vim', 'f-person/git-blame.nvim', - { 'folke/zen-mode.nvim', opts = { @@ -37,7 +17,6 @@ return { vim.api.nvim_set_keymap('n', 'zz', 'ZenMode', { noremap = true, silent = true }) end, }, - { 'nvim-lualine/lualine.nvim', config = function() @@ -104,13 +83,6 @@ return { dependencies = { "nvim-treesitter/nvim-treesitter" } }, - { - 'akinsho/flutter-tools.nvim', - requires = { - 'nvim-lua/plenary.nvim', - 'stevearc/dressing.nvim', -- optional for vim.ui.select - }, - }, { "danymat/neogen", config = true,