@@ -460,89 +460,112 @@ require('lazy').setup({
460460 })
461461 end , { desc = ' [/] Fuzzily search in current buffer' })
462462
463- -- It's also possible to pass additional configuration options.
464- -- See `:help telescope.builtin.live_grep()` for information about particular keys
465- vim .keymap .set (
466- ' n' ,
467- ' <leader>s/' ,
468- function ()
469- builtin .live_grep {
470- grep_open_files = true ,
471- prompt_title = ' Live Grep in Open Files' ,
472- }
473- end ,
474- { desc = ' [S]earch [/] in Open Files' }
475- )
476-
477- -- Shortcut for searching your Neovim configuration files
478- vim .keymap .set (' n' , ' <leader>sn' , function () builtin .find_files { cwd = vim .fn .stdpath ' config' } end , { desc = ' [S]earch [N]eovim files' })
479- end ,
480- },
481-
482- -- LSP Plugins
483- {
484- -- Main LSP Configuration
485- ' neovim/nvim-lspconfig' ,
486- dependencies = {
487- -- Automatically install LSPs and related tools to stdpath for Neovim
488- -- Mason must be loaded before its dependents so we need to set it up here.
489- -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
490- {
491- ' mason-org/mason.nvim' ,
492- --- @module ' mason.settings'
493- --- @type MasonSettings
494- --- @diagnostic disable-next-line : missing-fields
495- opts = {},
463+ local function telescope_live_grep_open_files ()
464+ require (' telescope.builtin' ).live_grep {
465+ grep_open_files = true ,
466+ prompt_title = ' Live Grep in Open Files' ,
467+ }
468+ end
469+ vim .keymap .set (' n' , ' <leader>s/' , telescope_live_grep_open_files , { desc = ' [S]earch [/] in Open Files' })
470+ vim .keymap .set (' n' , ' <leader>ss' , require (' telescope.builtin' ).builtin , { desc = ' [S]earch [S]elect Telescope' })
471+ vim .keymap .set (' n' , ' <leader>gf' , require (' telescope.builtin' ).git_files , { desc = ' Search [G]it [F]iles' })
472+ vim .keymap .set (' n' , ' <leader>sf' , require (' telescope.builtin' ).find_files , { desc = ' [S]earch [F]iles' })
473+ vim .keymap .set (' n' , ' <leader>sh' , require (' telescope.builtin' ).help_tags , { desc = ' [S]earch [H]elp' })
474+ vim .keymap .set (' n' , ' <leader>sw' , require (' telescope.builtin' ).grep_string , { desc = ' [S]earch current [W]ord' })
475+ vim .keymap .set (' n' , ' <leader>sg' , require (' telescope.builtin' ).live_grep , { desc = ' [S]earch by [G]rep' })
476+ vim .keymap .set (' n' , ' <leader>sG' , ' :LiveGrepGitRoot<cr>' , { desc = ' [S]earch by [G]rep on Git Root' })
477+ vim .keymap .set (' n' , ' <leader>sd' , require (' telescope.builtin' ).diagnostics , { desc = ' [S]earch [D]iagnostics' })
478+ vim .keymap .set (' n' , ' <leader>sr' , require (' telescope.builtin' ).resume , { desc = ' [S]earch [R]esume' })
479+
480+ -- [[ Configure Treesitter ]]
481+ -- See `:help nvim-treesitter`
482+ -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
483+ vim .defer_fn (function ()
484+ require (' nvim-treesitter.configs' ).setup {
485+ -- Add languages to be installed here that you want installed for treesitter
486+ ensure_installed = { ' c' , ' cpp' , ' go' , ' lua' , ' python' , ' rust' , ' tsx' , ' javascript' , ' typescript' , ' vimdoc' , ' vim' , ' bash' },
487+ -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
488+ auto_install = false ,
489+ -- Install languages synchronously (only applied to `ensure_installed`)
490+ sync_install = false ,
491+ -- List of parsers to ignore installing
492+ ignore_install = {},
493+ -- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- },
494+ modules = {},
495+ highlight = { enable = true },
496+ indent = { enable = true },
497+ incremental_selection = {
498+ enable = true ,
499+ keymaps = {
500+ init_selection = ' <c-space>' ,
501+ node_incremental = ' <c-space>' ,
502+ scope_incremental = ' <c-s>' ,
503+ node_decremental = ' <M-space>' ,
496504 },
497- -- Maps LSP server names between nvim-lspconfig and Mason package names.
498- ' mason-org/mason-lspconfig.nvim' ,
499- ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
500-
501- -- Useful status updates for LSP.
502- { ' j-hui/fidget.nvim' , opts = {} },
503505 },
504- config = function ()
505- -- Brief aside: **What is LSP?**
506- --
507- -- LSP is an initialism you've probably heard, but might not understand what it is.
508- --
509- -- LSP stands for Language Server Protocol. It's a protocol that helps editors
510- -- and language tooling communicate in a standardized fashion.
511- --
512- -- In general, you have a "server" which is some tool built to understand a particular
513- -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
514- -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
515- -- processes that communicate with some "client" - in this case, Neovim!
516- --
517- -- LSP provides Neovim with features like:
518- -- - Go to definition
519- -- - Find references
520- -- - Autocompletion
521- -- - Symbol Search
522- -- - and more!
523- --
524- -- Thus, Language Servers are external tools that must be installed separately from
525- -- Neovim. This is where `mason` and related plugins come into play.
526- --
527- -- If you're wondering about lsp vs treesitter, you can check out the wonderfully
528- -- and elegantly composed help section, `:help lsp-vs-treesitter`
529-
530- -- This function gets run when an LSP attaches to a particular buffer.
531- -- That is to say, every time a new file is opened that is associated with
532- -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
533- -- function will be executed to configure the current buffer
534- vim .api .nvim_create_autocmd (' LspAttach' , {
535- group = vim .api .nvim_create_augroup (' kickstart-lsp-attach' , { clear = true }),
536- callback = function (event )
537- -- NOTE: Remember that Lua is a real programming language, and as such it is possible
538- -- to define small helper and utility functions so you don't have to repeat yourself.
539- --
540- -- In this case, we create a function that lets us more easily define mappings specific
541- -- for LSP related items. It sets the mode, buffer and description for us each time.
542- local map = function (keys , func , desc , mode )
543- mode = mode or ' n'
544- vim .keymap .set (mode , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
545- end
506+ textobjects = {
507+ select = {
508+ enable = true ,
509+ lookahead = true , -- Automatically jump forward to textobj, similar to targets.vim
510+ keymaps = {
511+ -- You can use the capture groups defined in textobjects.scm
512+ [' aa' ] = ' @parameter.outer' ,
513+ [' ia' ] = ' @parameter.inner' ,
514+ [' af' ] = ' @function.outer' ,
515+ [' if' ] = ' @function.inner' ,
516+ [' ac' ] = ' @class.outer' ,
517+ [' ic' ] = ' @class.inner' ,
518+ },
519+ },
520+ move = {
521+ enable = true ,
522+ set_jumps = true , -- whether to set jumps in the jumplist
523+ goto_next_start = {
524+ [' ]m' ] = ' @function.outer' ,
525+ [' ]]' ] = ' @class.outer' ,
526+ },
527+ goto_next_end = {
528+ [' ]M' ] = ' @function.outer' ,
529+ [' ][' ] = ' @class.outer' ,
530+ },
531+ goto_previous_start = {
532+ [' [m' ] = ' @function.outer' ,
533+ [' [[' ] = ' @class.outer' ,
534+ },
535+ goto_previous_end = {
536+ [' [M' ] = ' @function.outer' ,
537+ [' []' ] = ' @class.outer' ,
538+ },
539+ },
540+ swap = {
541+ enable = true ,
542+ swap_next = {
543+ [' <leader>a' ] = ' @parameter.inner' ,
544+ },
545+ swap_previous = {
546+ [' <leader>A' ] = ' @parameter.inner' ,
547+ },
548+ },
549+ },
550+ }
551+ end , 0 )
552+
553+ -- [[ Configure LSP ]]
554+ -- This function gets run when an LSP connects to a particular buffer.
555+ local on_attach = function (_ , bufnr )
556+ -- NOTE: Remember that lua is a real programming language, and as such it is possible
557+ -- to define small helper and utility functions so you don't have to repeat yourself
558+ -- many times.
559+ --
560+ -- In this case, we create a function that lets us more easily define mappings specific
561+ -- for LSP related items. It sets the mode, buffer and description for us each time.
562+ local nmap = function (keys , func , desc )
563+ if desc then
564+ desc = ' LSP: ' .. desc
565+ end
566+
567+ vim .keymap .set (' n' , keys , func , { buffer = bufnr , desc = desc })
568+ end
546569
547570 -- Rename the variable under your cursor.
548571 -- Most Language Servers support renaming across files, etc.
0 commit comments