init.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. --[[
  2. =====================================================================
  3. ==================== READ THIS BEFORE CONTINUING ====================
  4. =====================================================================
  5. Kickstart.nvim is *not* a distribution.
  6. Kickstart.nvim is a template for your own configuration.
  7. The goal is that you can read every line of code, top-to-bottom, understand
  8. what your configuration is doing, and modify it to suit your needs.
  9. Once you've done that, you should start exploring, configuring and tinkering to
  10. explore Neovim!
  11. If you don't know anything about Lua, I recommend taking some time to read through
  12. a guide. One possible example:
  13. - https://learnxinyminutes.com/docs/lua/
  14. And then you can explore or search through `:help lua-guide`
  15. - https://neovim.io/doc/user/lua-guide.html
  16. Kickstart Guide:
  17. I have left several `:help X` comments throughout the init.lua
  18. You should run that command and read that help section for more information.
  19. In addition, I have some `NOTE:` items throughout the file.
  20. These are for you, the reader to help understand what is happening. Feel free to delete
  21. them once you know what you're doing, but they should serve as a guide for when you
  22. are first encountering a few different constructs in your nvim config.
  23. I hope you enjoy your Neovim journey,
  24. - TJ
  25. P.S. You can delete this when you're done too. It's your config now :)
  26. --]]
  27. -- Set <space> as the leader key
  28. -- See `:help mapleader`
  29. -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
  30. vim.g.mapleader = ' '
  31. vim.g.maplocalleader = ' '
  32. -- [[ Install `lazy.nvim` plugin manager ]]
  33. -- https://github.com/folke/lazy.nvim
  34. -- `:help lazy.nvim.txt` for more info
  35. local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
  36. if not vim.loop.fs_stat(lazypath) then
  37. vim.fn.system {
  38. 'git',
  39. 'clone',
  40. '--filter=blob:none',
  41. 'https://github.com/folke/lazy.nvim.git',
  42. '--branch=stable', -- latest stable release
  43. lazypath,
  44. }
  45. end
  46. vim.opt.rtp:prepend(lazypath)
  47. -- [[ Configure plugins ]]
  48. -- NOTE: Here is where you install your plugins.
  49. -- You can configure plugins using the `config` key.
  50. --
  51. -- You can also configure plugins after the setup call,
  52. -- as they will be available in your neovim runtime.
  53. require('lazy').setup({
  54. -- NOTE: First, some plugins that don't require any configuration
  55. -- Git related plugins
  56. 'tpope/vim-fugitive',
  57. 'tpope/vim-rhubarb',
  58. -- Detect tabstop and shiftwidth automatically
  59. 'tpope/vim-sleuth',
  60. -- NOTE: This is where your plugins related to LSP can be installed.
  61. -- The configuration is done below. Search for lspconfig to find it below.
  62. {
  63. -- LSP Configuration & Plugins
  64. 'neovim/nvim-lspconfig',
  65. dependencies = {
  66. -- Automatically install LSPs to stdpath for neovim
  67. 'williamboman/mason.nvim',
  68. 'williamboman/mason-lspconfig.nvim',
  69. -- Useful status updates for LSP
  70. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
  71. { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
  72. -- Additional lua configuration, makes nvim stuff amazing!
  73. 'folke/neodev.nvim',
  74. },
  75. },
  76. {
  77. -- Autocompletion
  78. 'hrsh7th/nvim-cmp',
  79. dependencies = {
  80. -- Snippet Engine & its associated nvim-cmp source
  81. 'L3MON4D3/LuaSnip',
  82. 'saadparwaiz1/cmp_luasnip',
  83. -- Adds LSP completion capabilities
  84. 'hrsh7th/cmp-nvim-lsp',
  85. -- Adds a number of user-friendly snippets
  86. 'rafamadriz/friendly-snippets',
  87. },
  88. },
  89. -- Useful plugin to show you pending keybinds.
  90. { 'folke/which-key.nvim', opts = {} },
  91. {
  92. -- Adds git related signs to the gutter, as well as utilities for managing changes
  93. 'lewis6991/gitsigns.nvim',
  94. opts = {
  95. -- See `:help gitsigns.txt`
  96. signs = {
  97. add = { text = '+' },
  98. change = { text = '~' },
  99. delete = { text = '_' },
  100. topdelete = { text = '‾' },
  101. changedelete = { text = '~' },
  102. },
  103. on_attach = function(bufnr)
  104. vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' })
  105. -- don't override the built-in and fugitive keymaps
  106. local gs = package.loaded.gitsigns
  107. vim.keymap.set({ 'n', 'v' }, ']c', function()
  108. if vim.wo.diff then
  109. return ']c'
  110. end
  111. vim.schedule(function()
  112. gs.next_hunk()
  113. end)
  114. return '<Ignore>'
  115. end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' })
  116. vim.keymap.set({ 'n', 'v' }, '[c', function()
  117. if vim.wo.diff then
  118. return '[c'
  119. end
  120. vim.schedule(function()
  121. gs.prev_hunk()
  122. end)
  123. return '<Ignore>'
  124. end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' })
  125. end,
  126. },
  127. },
  128. {
  129. -- Theme inspired by Atom
  130. 'navarasu/onedark.nvim',
  131. priority = 1000,
  132. config = function()
  133. vim.cmd.colorscheme 'onedark'
  134. end,
  135. },
  136. {
  137. -- Set lualine as statusline
  138. 'nvim-lualine/lualine.nvim',
  139. -- See `:help lualine.txt`
  140. opts = {
  141. options = {
  142. icons_enabled = false,
  143. theme = 'onedark',
  144. component_separators = '|',
  145. section_separators = '',
  146. },
  147. },
  148. },
  149. {
  150. -- Add indentation guides even on blank lines
  151. 'lukas-reineke/indent-blankline.nvim',
  152. -- Enable `lukas-reineke/indent-blankline.nvim`
  153. -- See `:help ibl`
  154. main = 'ibl',
  155. opts = {},
  156. },
  157. -- "gc" to comment visual regions/lines
  158. { 'numToStr/Comment.nvim', opts = {} },
  159. -- Fuzzy Finder (files, lsp, etc)
  160. {
  161. 'nvim-telescope/telescope.nvim',
  162. branch = '0.1.x',
  163. dependencies = {
  164. 'nvim-lua/plenary.nvim',
  165. -- Fuzzy Finder Algorithm which requires local dependencies to be built.
  166. -- Only load if `make` is available. Make sure you have the system
  167. -- requirements installed.
  168. {
  169. 'nvim-telescope/telescope-fzf-native.nvim',
  170. -- NOTE: If you are having trouble with this installation,
  171. -- refer to the README for telescope-fzf-native for more instructions.
  172. build = 'make',
  173. cond = function()
  174. return vim.fn.executable 'make' == 1
  175. end,
  176. },
  177. },
  178. },
  179. {
  180. -- Highlight, edit, and navigate code
  181. 'nvim-treesitter/nvim-treesitter',
  182. dependencies = {
  183. 'nvim-treesitter/nvim-treesitter-textobjects',
  184. },
  185. build = ':TSUpdate',
  186. },
  187. -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
  188. -- These are some example plugins that I've included in the kickstart repository.
  189. -- Uncomment any of the lines below to enable them.
  190. -- require 'kickstart.plugins.autoformat',
  191. -- require 'kickstart.plugins.debug',
  192. -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
  193. -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
  194. -- up-to-date with whatever is in the kickstart repo.
  195. -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
  196. --
  197. -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
  198. -- { import = 'custom.plugins' },
  199. }, {})
  200. -- [[ Setting options ]]
  201. -- See `:help vim.o`
  202. -- NOTE: You can change these options as you wish!
  203. -- Set highlight on search
  204. vim.o.hlsearch = false
  205. -- Make line numbers default
  206. vim.wo.number = true
  207. -- Enable mouse mode
  208. vim.o.mouse = 'a'
  209. -- Sync clipboard between OS and Neovim.
  210. -- Remove this option if you want your OS clipboard to remain independent.
  211. -- See `:help 'clipboard'`
  212. vim.o.clipboard = 'unnamedplus'
  213. -- Enable break indent
  214. vim.o.breakindent = true
  215. -- Save undo history
  216. vim.o.undofile = true
  217. -- Case-insensitive searching UNLESS \C or capital in search
  218. vim.o.ignorecase = true
  219. vim.o.smartcase = true
  220. -- Keep signcolumn on by default
  221. vim.wo.signcolumn = 'yes'
  222. -- Decrease update time
  223. vim.o.updatetime = 250
  224. vim.o.timeoutlen = 300
  225. -- Set completeopt to have a better completion experience
  226. vim.o.completeopt = 'menuone,noselect'
  227. -- NOTE: You should make sure your terminal supports this
  228. vim.o.termguicolors = true
  229. -- [[ Basic Keymaps ]]
  230. -- Keymaps for better default experience
  231. -- See `:help vim.keymap.set()`
  232. vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
  233. -- Remap for dealing with word wrap
  234. vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
  235. vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
  236. -- Diagnostic keymaps
  237. vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
  238. vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
  239. vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
  240. vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
  241. -- [[ Highlight on yank ]]
  242. -- See `:help vim.highlight.on_yank()`
  243. local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
  244. vim.api.nvim_create_autocmd('TextYankPost', {
  245. callback = function()
  246. vim.highlight.on_yank()
  247. end,
  248. group = highlight_group,
  249. pattern = '*',
  250. })
  251. -- [[ Configure Telescope ]]
  252. -- See `:help telescope` and `:help telescope.setup()`
  253. require('telescope').setup {
  254. defaults = {
  255. mappings = {
  256. i = {
  257. ['<C-u>'] = false,
  258. ['<C-d>'] = false,
  259. },
  260. },
  261. },
  262. }
  263. -- Enable telescope fzf native, if installed
  264. pcall(require('telescope').load_extension, 'fzf')
  265. -- Telescope live_grep in git root
  266. -- Function to find the git root directory based on the current buffer's path
  267. local function find_git_root()
  268. -- Use the current buffer's path as the starting point for the git search
  269. local current_file = vim.api.nvim_buf_get_name(0)
  270. local current_dir
  271. local cwd = vim.fn.getcwd()
  272. -- If the buffer is not associated with a file, return nil
  273. if current_file == "" then
  274. current_dir = cwd
  275. else
  276. -- Extract the directory from the current file's path
  277. current_dir = vim.fn.fnamemodify(current_file, ":h")
  278. end
  279. -- Find the Git root directory from the current file's path
  280. local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1]
  281. if vim.v.shell_error ~= 0 then
  282. print("Not a git repository. Searching on current working directory")
  283. return cwd
  284. end
  285. return git_root
  286. end
  287. -- Custom live_grep function to search in git root
  288. local function live_grep_git_root()
  289. local git_root = find_git_root()
  290. if git_root then
  291. require('telescope.builtin').live_grep({
  292. search_dirs = {git_root},
  293. })
  294. end
  295. end
  296. vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
  297. -- See `:help telescope.builtin`
  298. vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
  299. vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
  300. vim.keymap.set('n', '<leader>/', function()
  301. -- You can pass additional configuration to telescope to change theme, layout, etc.
  302. require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
  303. winblend = 10,
  304. previewer = false,
  305. })
  306. end, { desc = '[/] Fuzzily search in current buffer' })
  307. vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
  308. vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
  309. vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
  310. vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
  311. vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
  312. vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
  313. vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
  314. vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
  315. -- [[ Configure Treesitter ]]
  316. -- See `:help nvim-treesitter`
  317. -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
  318. vim.defer_fn(function()
  319. require('nvim-treesitter.configs').setup {
  320. -- Add languages to be installed here that you want installed for treesitter
  321. ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' },
  322. -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
  323. auto_install = false,
  324. highlight = { enable = true },
  325. indent = { enable = true },
  326. incremental_selection = {
  327. enable = true,
  328. keymaps = {
  329. init_selection = '<c-space>',
  330. node_incremental = '<c-space>',
  331. scope_incremental = '<c-s>',
  332. node_decremental = '<M-space>',
  333. },
  334. },
  335. textobjects = {
  336. select = {
  337. enable = true,
  338. lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
  339. keymaps = {
  340. -- You can use the capture groups defined in textobjects.scm
  341. ['aa'] = '@parameter.outer',
  342. ['ia'] = '@parameter.inner',
  343. ['af'] = '@function.outer',
  344. ['if'] = '@function.inner',
  345. ['ac'] = '@class.outer',
  346. ['ic'] = '@class.inner',
  347. },
  348. },
  349. move = {
  350. enable = true,
  351. set_jumps = true, -- whether to set jumps in the jumplist
  352. goto_next_start = {
  353. [']m'] = '@function.outer',
  354. [']]'] = '@class.outer',
  355. },
  356. goto_next_end = {
  357. [']M'] = '@function.outer',
  358. [']['] = '@class.outer',
  359. },
  360. goto_previous_start = {
  361. ['[m'] = '@function.outer',
  362. ['[['] = '@class.outer',
  363. },
  364. goto_previous_end = {
  365. ['[M'] = '@function.outer',
  366. ['[]'] = '@class.outer',
  367. },
  368. },
  369. swap = {
  370. enable = true,
  371. swap_next = {
  372. ['<leader>a'] = '@parameter.inner',
  373. },
  374. swap_previous = {
  375. ['<leader>A'] = '@parameter.inner',
  376. },
  377. },
  378. },
  379. }
  380. end, 0)
  381. -- [[ Configure LSP ]]
  382. -- This function gets run when an LSP connects to a particular buffer.
  383. local on_attach = function(_, bufnr)
  384. -- NOTE: Remember that lua is a real programming language, and as such it is possible
  385. -- to define small helper and utility functions so you don't have to repeat yourself
  386. -- many times.
  387. --
  388. -- In this case, we create a function that lets us more easily define mappings specific
  389. -- for LSP related items. It sets the mode, buffer and description for us each time.
  390. local nmap = function(keys, func, desc)
  391. if desc then
  392. desc = 'LSP: ' .. desc
  393. end
  394. vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
  395. end
  396. nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
  397. nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
  398. nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
  399. nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
  400. nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
  401. nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
  402. nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
  403. nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
  404. -- See `:help K` for why this keymap
  405. nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
  406. nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
  407. -- Lesser used LSP functionality
  408. nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
  409. nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
  410. nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
  411. nmap('<leader>wl', function()
  412. print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
  413. end, '[W]orkspace [L]ist Folders')
  414. -- Create a command `:Format` local to the LSP buffer
  415. vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
  416. vim.lsp.buf.format()
  417. end, { desc = 'Format current buffer with LSP' })
  418. end
  419. -- document existing key chains
  420. require('which-key').register {
  421. ['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
  422. ['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
  423. ['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
  424. ['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
  425. ['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
  426. ['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
  427. ['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
  428. }
  429. -- mason-lspconfig requires that these setup functions are called in this order
  430. -- before setting up the servers.
  431. require('mason').setup()
  432. require('mason-lspconfig').setup()
  433. -- Enable the following language servers
  434. -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
  435. --
  436. -- Add any additional override configuration in the following tables. They will be passed to
  437. -- the `settings` field of the server config. You must look up that documentation yourself.
  438. --
  439. -- If you want to override the default filetypes that your language server will attach to you can
  440. -- define the property 'filetypes' to the map in question.
  441. local servers = {
  442. -- clangd = {},
  443. -- gopls = {},
  444. -- pyright = {},
  445. -- rust_analyzer = {},
  446. -- tsserver = {},
  447. -- html = { filetypes = { 'html', 'twig', 'hbs'} },
  448. lua_ls = {
  449. Lua = {
  450. workspace = { checkThirdParty = false },
  451. telemetry = { enable = false },
  452. },
  453. },
  454. }
  455. -- Setup neovim lua configuration
  456. require('neodev').setup()
  457. -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
  458. local capabilities = vim.lsp.protocol.make_client_capabilities()
  459. capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
  460. -- Ensure the servers above are installed
  461. local mason_lspconfig = require 'mason-lspconfig'
  462. mason_lspconfig.setup {
  463. ensure_installed = vim.tbl_keys(servers),
  464. }
  465. mason_lspconfig.setup_handlers {
  466. function(server_name)
  467. require('lspconfig')[server_name].setup {
  468. capabilities = capabilities,
  469. on_attach = on_attach,
  470. settings = servers[server_name],
  471. filetypes = (servers[server_name] or {}).filetypes,
  472. }
  473. end,
  474. }
  475. -- [[ Configure nvim-cmp ]]
  476. -- See `:help cmp`
  477. local cmp = require 'cmp'
  478. local luasnip = require 'luasnip'
  479. require('luasnip.loaders.from_vscode').lazy_load()
  480. luasnip.config.setup {}
  481. cmp.setup {
  482. snippet = {
  483. expand = function(args)
  484. luasnip.lsp_expand(args.body)
  485. end,
  486. },
  487. completion = {
  488. completeopt = 'menu,menuone,noinsert'
  489. },
  490. mapping = cmp.mapping.preset.insert {
  491. ['<C-n>'] = cmp.mapping.select_next_item(),
  492. ['<C-p>'] = cmp.mapping.select_prev_item(),
  493. ['<C-d>'] = cmp.mapping.scroll_docs(-4),
  494. ['<C-f>'] = cmp.mapping.scroll_docs(4),
  495. ['<C-Space>'] = cmp.mapping.complete {},
  496. ['<CR>'] = cmp.mapping.confirm {
  497. behavior = cmp.ConfirmBehavior.Replace,
  498. select = true,
  499. },
  500. ['<Tab>'] = cmp.mapping(function(fallback)
  501. if cmp.visible() then
  502. cmp.select_next_item()
  503. elseif luasnip.expand_or_locally_jumpable() then
  504. luasnip.expand_or_jump()
  505. else
  506. fallback()
  507. end
  508. end, { 'i', 's' }),
  509. ['<S-Tab>'] = cmp.mapping(function(fallback)
  510. if cmp.visible() then
  511. cmp.select_prev_item()
  512. elseif luasnip.locally_jumpable(-1) then
  513. luasnip.jump(-1)
  514. else
  515. fallback()
  516. end
  517. end, { 'i', 's' }),
  518. },
  519. sources = {
  520. { name = 'nvim_lsp' },
  521. { name = 'luasnip' },
  522. },
  523. }
  524. -- The line beneath this is called `modeline`. See `:help modeline`
  525. -- vim: ts=2 sts=2 sw=2 et