Full Code of tjdevries/advent-of-nvim for AI

master 13d4ec68a2a8 cached
27 files
22.9 KB
7.8k tokens
1 requests
Download .txt
Repository: tjdevries/advent-of-nvim
Branch: master
Commit: 13d4ec68a2a8
Files: 27
Total size: 22.9 KB

Directory structure:
gitextract_ro4vkjfw/

├── 01 - Introduction/
│   └── 01 - Introduction.md
├── 02 - Tutor and Modal Editing/
│   └── 02 - Tutor and Modal Editing.md
├── 03 - Lua Crash Course/
│   ├── 03 - Lua Crash Course.md
│   └── init.lua
├── 04 - Package Manager/
│   ├── Package Manager.md
│   └── init.lua
├── Makefile
├── README.md
├── XX - oil/
│   ├── Oil.md
│   └── config/
│       ├── init.lua
│       ├── lazy-lock.json
│       └── lua/
│           └── config/
│               ├── lazy.lua
│               └── plugins/
│                   ├── mini.lua
│                   └── oil.lua
└── nvim/
    ├── after/
    │   └── ftplugin/
    │       └── lua.lua
    ├── init.lua
    ├── lazy-lock.json
    ├── lua/
    │   └── config/
    │       ├── lazy.lua
    │       ├── plugins/
    │       │   ├── completion.lua
    │       │   ├── lsp.lua
    │       │   ├── mini.lua
    │       │   ├── oil.lua
    │       │   ├── telescope.lua
    │       │   └── treesitter.lua
    │       └── telescope/
    │           └── multigrep.lua
    └── plugin/
        ├── floaterminal.lua
        └── menu.lua

================================================
FILE CONTENTS
================================================

================================================
FILE: 01 - Introduction/01 - Introduction.md
================================================
# Introduction to Neovim

## Why Do I Use Neovim?

## Why Do I Use Neovim?

- I find it very satisfying to make things just the way I like
- It makes my day more fun - both hacking on it and eliminating frustrations
- I like modal editing - it clicks with my brain.

## How to Use Neovim?

- Download and/or Package Manager:
    - https://neovim.io/doc/
- Build From Source:
    - https://github.com/neovim/neovim/blob/master/BUILD.md

## First Configuration:

- Open `$HOME/.config/nvim/init.lua`
- `print("Hello World")` in `init.lua`
- Re-open Neovim, check `:messages`

## Reload Configuration:

- `:source %`
- `:lua ...` or `:'<,'>lua`


================================================
FILE: 02 - Tutor and Modal Editing/02 - Tutor and Modal Editing.md
================================================
# Vim Tutor: Explained

## First

- You have to actually practice
- Don't just listen to me

## How to practice?

Open Neovim.

`:Tutor`

## How to practice?

> But it's confusing?!

Ok, I will do it with you :)


================================================
FILE: 03 - Lua Crash Course/03 - Lua Crash Course.md
================================================
# Lua Crash Course

## Table of Contents

- Comments
- Variables
- Control Flow
- Modules
- Functions
- Metatables
- Bonus :)

## Background Info

Lua is elegant

- Lua uses "Mechanisms over Policies"
- Lua is designed to be embedded
- Lua is cool

## Comments

```lua
-- This is a comment. It starts with two dashes

--[[ This is also
     a comment.

     But it spans multiple lines!
--]]
```

## Variables: Simple Literals

```lua
local number = 5

local string = "hello, world"
local single = 'also works'
local crazy = [[ This
 is multi line and literal ]]

local truth, lies = true, false

local nothing = nil
```

## Variables: Functions

```lua
local function hello(name)
  print("Hello!", name)
end

local greet = function(name)
  -- .. is string concatenation
  print("Greetings, " .. name .. "!")
end
```

## Variables: Functions

```lua
local higher_order = function(value)
  return function(another)
    return value + another
  end
end

local add_one = higher_order(1)
print("add_one(2) -> ", add_one(2))
```

## Variables: Tables

Effectively, Lua's only data structure.
- Same structure is used for maps & lists

## Variables: Tables

As a list...

```lua
local list = { "first", 2, false, function() print("Fourth!") end }
print("Yup, 1-indexed:", list[1])
print("Fourth is 4...:", list[4]())
```
## Variables: Tables

As a map...

```lua
local t = {
  literal_key = "a string",
  ["an expression"] = "also works",
  [function() end] = true
}

print("literal_key   : ", t.literal_key)
print("an expression : ", t["an expression"])
print("function() end: ", t[function() end])
```

## Variables: Not Covered

- Thread
- Userdata

## Control Flow: `for`

```lua
local favorite_accounts = { "teej_dv", "ThePrimeagen", "terminaldotshop" }
for index = 1, #favorite_accounts do
  print(index, favorite_accounts[index])
end

for index, value in ipairs(favorite_accounts) do
  print(index, value)
end
```

## Control Flow: `for`

```lua
local reading_scores = { teej_dv = 10, ThePrimeagen = "N/A" }
for index = 1, #reading_scores do
  print(reading_scores[index])
end
```

Doesn't Print Anything - the "length" of the array is 0.

We aren't using it as an array, we're using it as a map!


## Control Flow: `for`

```lua
local reading_scores = { teej_dv = 9.5, ThePrimeagen = "N/A" }
for key, value in pairs(reading_scores) do
  print(key, value)
end
```

## Control Flow: `if`

```lua
local function action(loves_coffee)
  if loves_coffee then
    print("Check out `ssh terminal.shop` - it's cool!")
  else
    print("Check out `ssh terminal.shop` - it's still cool!")
  end
end

-- "falsey": nil, false
action() -- Same as: action(nil)
action(false)

-- Everything else is "truthy"
action(true)
action(0)
action({})
```

## Modules

There isn't anything special about modules.
Modules are just files!

```lua
-- foo.lua
local M = {}
M.cool_function = function() end
return M
```

```lua
-- bar.lua
local foo = require('foo')
foo.cool_function()
```

## Functions: Multiple Returns

```lua
local returns_four_values = function()
  return 1, 2, 3, 4
end

first, second, last = returns_four_values()

print("first: ", first)
print("second:", second)
print("last:  ", last)
-- the `4` is discarded :'(
```

## Functions: Multiple Returns

```lua
local variable_arguments = function(...)
  local arguments = { ... }
  for i, v in ipairs({...}) do print(i, v) end
  return unpack(arguments)
end

print("===================")
print("1:", variable_arguments("hello", "world", "!"))
print("===================")
print("2:", variable_arguments("hello", "world", "!"), "<lost>")
```

## Functions: Calling

String Shorthand

```lua
local single_string = function(s)
  return s .. " - WOW!"
end

local x = single_string("hi")
local y = single_string "hi"
print(x, y)
```

## Functions: Calling

Table Shorthand

```lua
local setup = function(opts)
  if opts.default == nil then
    opts.default = 17
  end

  print(opts.default, opts.other)
end

setup { default = 12, other = false}
setup { other = true}
```

## Functions: Colon Functions

```lua
local MyTable = {}

function MyTable.something(self, ...) end
function MyTable:something(...) end
```

## Metatables

```lua
local vector_mt = {}
vector_mt.__add = function(left, right)
  return setmetatable({
    left[1] + right[1],
    left[2] + right[2],
    left[3] + right[3],
  }, vector_mt)
end

local v1 = setmetatable({ 3, 1, 5 }, vector_mt)
local v2 = setmetatable({ -3, 2, 2 }, vector_mt)
local v3 = v1 + v2
vim.print(v3[1], v3[2], v3[3])
vim.print(v3 + v3)
```

## Metatables

```lua
local fib_mt = {
  __index = function(self, key)
    if key < 2 then return 1 end
    -- Update the table, to save the intermediate results
    self[key] = self[key - 2] + self[key - 1]
    -- Return the result
    return self[key]
  end
}

local fib = setmetatable({}, fib_mt)

print(fib[5])
print(fib[1000])
```

## Metatables

Other notable fields:

- `__newindex(self, key, value)`
- `__call(self, ...)`

## Quick Neovim Goodies

```lua
vim.keymap.set("n", "<space><space>x", "<cmd>source %<CR>")
vim.keymap.set("n", "<space>x", ":.lua<CR>")
vim.keymap.set("v", "<space>x", ":lua<CR>")
```

## Quick Neovim Goodies

```lua
-- Highlight when yanking (copying) text
--  Try it with `yap` in normal mode
--  See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
  desc = 'Highlight when yanking (copying) text',
  group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
  callback = function()
    vim.highlight.on_yank()
  end,
})
```


================================================
FILE: 03 - Lua Crash Course/init.lua
================================================
-- Day 3
print("advent of neovim")

vim.keymap.set("n", "<space><space>x", "<cmd>source %<CR>")
vim.keymap.set("n", "<space>x", ":.lua<CR>")
vim.keymap.set("v", "<space>x", ":lua<CR>")

-- Highlight when yanking (copying) text
--  Try it with `yap` in normal mode
--  See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
	desc = "Highlight when yanking (copying) text",
	group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
	callback = function()
		vim.highlight.on_yank()
	end,
})


================================================
FILE: 04 - Package Manager/Package Manager.md
================================================
# Package Manager

## Package Manager

Going to use `lazy.nvim`
- https://lazy.folke.io/installation

NOTE: which is different from LazyVim

## Install

(follow instructions)

`:checkhealth lazy`

## Install a colorscheme

- Tokyo Night Color Scheme
    - https://github.com/folke/tokyonight.nvim

```lua
{ "folke/tokyonight.nvim", config = function() vim.cmd.colorscheme "tokyonight" end }
```

## Install `mini`

- Mini.nvim
    - https://github.com/echasnovski/mini.nvim

- Setup statusline

```lua
-- lua/custom/plugins/mini.lua
return {
    {
        'echasnovski/mini.nvim',
        config = function()
            local statusline = require 'mini.statusline'
            statusline.setup { use_icons = true }
        end
    }
}
```


================================================
FILE: 04 - Package Manager/init.lua
================================================
print("advent of neovim")
print("advent of neovim")


vim.keymap.set("n", "<space><space>x", "<cmd>source %<CR>")
vim.keymap.set("n", "<space>x", ":.lua<CR>")
vim.keymap.set("v", "<space>x", ":lua<CR>")

-- Highlight when yanking (copying) text
--  Try it with `yap` in normal mode
--  See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
  desc = 'Highlight when yanking (copying) text',
  group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
  callback = function()
    vim.highlight.on_yank()
  end,
})


================================================
FILE: Makefile
================================================
update:
	rm -rf ./nvim
	mkdir nvim
	cp -rf ~/.config/nvimexample/* ./nvim/



================================================
FILE: README.md
================================================
# Advent of `nvim`

Check the config in: `./nvim/`
- This should be versioned roughly by day, so you can go back and check how each day was made.
- You likely could copy this into `~/.config/` to get the same config as in the video, but I make no guarantees about that.


25 Mini Lessons to get started with Neovim.
- We'll build a working configuration that resembles kickstart.nvim, but we'll do it completely from scratch.

- [x] Install Neovim and Open (with some reasons why)
- [x] Tutor / Modal Editing
- [x] Lua Configuration (Options / Keymaps)
- [x] Plugin Manager
- [x] Filetype configuration
- `tree-sitter`
- [x] LSP (Keymaps and Settings)
- [x] Autoformat
- [x] Telescope
- [x] Advanced Telescope: multi-ripgrep
- [x] Window Navigation
- [x] Quickfix: `:cdo` and others
- [x] Terminal (Escape, Floating, Usages)
- [x] Autocomplete
- [x] Oil.nvim
    - Longer video: https://youtu.be/218PFRsvu2o?si=l8UFf2Z7YdUKU0KJ
- [x] Mouse Menu LOL
- LSP Installation / Management
- Snippets
- text-objects: `mini.*`
- Tree-sitter: text-objects
- Language Configuration
- Clipboard


================================================
FILE: XX - oil/Oil.md
================================================


================================================
FILE: XX - oil/config/init.lua
================================================
print("advent of neovim")

require("config.lazy")

vim.keymap.set("n", "<space><space>x", "<cmd>source %<CR>")
vim.keymap.set("n", "<space>x", ":.lua<CR>")
vim.keymap.set("v", "<space>x", ":lua<CR>")

-- Highlight when yanking (copying) text
--  Try it with `yap` in normal mode
--  See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
  desc = 'Highlight when yanking (copying) text',
  group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
  callback = function()
    vim.highlight.on_yank()
  end,
})


================================================
FILE: XX - oil/config/lazy-lock.json
================================================
{
  "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" },
  "mini.nvim": { "branch": "main", "commit": "690a3b4c78c4956f7ecf770124b522d32084b872" },
  "tokyonight.nvim": { "branch": "main", "commit": "15d83cda572d7498b43bbdaa223bc75bf341183e" }
}


================================================
FILE: XX - oil/config/lua/config/lazy.lua
================================================
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end

-- Hey! Put lazy into the runtimepath for neovim!
vim.opt.runtimepath:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
  spec = {
    { "folke/tokyonight.nvim", config = function() vim.cmd.colorscheme "tokyonight" end },
    { import = "config.plugins" },
  },
})


================================================
FILE: XX - oil/config/lua/config/plugins/mini.lua
================================================
-- lua/custom/plugins/mini.lua
return {
    {
        'echasnovski/mini.nvim',
	enabled = true,
        config = function()
            local statusline = require 'mini.statusline'
            statusline.setup { use_icons = true }
        end
    },
}


================================================
FILE: XX - oil/config/lua/config/plugins/oil.lua
================================================
return {
	{
		"stevearc/oil.nvim",
		dependencies = { "nvim-tree/nvim-web-devicons" },
		config = function()
			require("oil").setup({
				columns = { "icon" },
				keymaps = {
					["<C-h>"] = false,
					["<C-l>"] = false,
					["<C-k>"] = false,
					["<C-j>"] = false,
					["<M-h>"] = "actions.select_split",
				},
				view_options = { show_hidden = true },
			})

			-- Open parent directory in current window
			vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
		end,
	},
}


================================================
FILE: nvim/after/ftplugin/lua.lua
================================================
local set = vim.opt_local

set.shiftwidth = 2
set.number = true
set.relativenumber = true


================================================
FILE: nvim/init.lua
================================================
print("advent of neovim")

require("config.lazy")

vim.opt.shiftwidth = 4
vim.opt.clipboard = "unnamedplus"
vim.opt.number = true
vim.opt.relativenumber = true

vim.keymap.set("n", "<space><space>x", "<cmd>source %<CR>")
vim.keymap.set("n", "<space>x", ":.lua<CR>")
vim.keymap.set("v", "<space>x", ":lua<CR>")

vim.keymap.set("n", "<M-j>", "<cmd>cnext<CR>")
vim.keymap.set("n", "<M-k>", "<cmd>cprev<CR>")

-- Highlight when yanking (copying) text
--  Try it with `yap` in normal mode
--  See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
  desc = "Highlight when yanking (copying) text",
  group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
  callback = function()
    vim.highlight.on_yank()
  end,
})

vim.api.nvim_create_autocmd("TermOpen", {
  group = vim.api.nvim_create_augroup("custom-term-open", { clear = true }),
  callback = function()
    vim.opt.number = false
    vim.opt.relativenumber = false
  end,
})

local job_id = 0
vim.keymap.set("n", "<space>to", function()
  vim.cmd.vnew()
  vim.cmd.term()
  vim.cmd.wincmd("J")
  vim.api.nvim_win_set_height(0, 5)

  job_id = vim.bo.channel
end)

local current_command = ""
vim.keymap.set("n", "<space>te", function()
  current_command = vim.fn.input("Command: ")
end)

vim.keymap.set("n", "<space>tr", function()
  if current_command == "" then
    current_command = vim.fn.input("Command: ")
  end

  vim.fn.chansend(job_id, { current_command .. "\r\n" })
end)

vim.keymap.set("n", "-", "<cmd>Oil<CR>")


================================================
FILE: nvim/lazy-lock.json
================================================
{
  "blink.cmp": { "branch": "main", "commit": "ae5a4ce8f7e519e49de7ae6fcadd74547f820a52" },
  "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
  "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
  "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" },
  "mini.icons": { "branch": "main", "commit": "44c0160526f7ae17ca8e8eab9ab235d047fcf7a6" },
  "mini.nvim": { "branch": "main", "commit": "7ebfab26d77a4b9b05aaae565907e7fa4b2ee154" },
  "nvim-lspconfig": { "branch": "master", "commit": "9f2c279cf9abe584f03bfeb37c6658d68e3ff49d" },
  "nvim-treesitter": { "branch": "master", "commit": "981ca7e353da6ea69eaafe4348fda5e800f9e1d8" },
  "oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" },
  "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
  "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" },
  "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
  "tokyonight.nvim": { "branch": "main", "commit": "45d22cf0e1b93476d3b6d362d720412b3d34465c" }
}


================================================
FILE: nvim/lua/config/lazy.lua
================================================
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		vim.api.nvim_echo({
			{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
			{ out,                            "WarningMsg" },
			{ "\nPress any key to exit..." },
		}, true, {})
		vim.fn.getchar()
		os.exit(1)
	end
end

-- Hey! Put lazy into the runtimepath for neovim!
vim.opt.runtimepath:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
	spec = {
		{ "folke/tokyonight.nvim",  config = function() vim.cmd.colorscheme "tokyonight" end },
		{ import = "config.plugins" },
	},
	change_detection = {
		-- automatically check for config file changes and reload the ui
		enabled = false,
		notify = false, -- get a notification when changes are found
	},
})


================================================
FILE: nvim/lua/config/plugins/completion.lua
================================================
return {
  {
    'saghen/blink.cmp',
    dependencies = 'rafamadriz/friendly-snippets',

    version = 'v0.*',

    opts = {
      keymap = { preset = 'default' },

      appearance = {
        use_nvim_cmp_as_default = true,
        nerd_font_variant = 'mono'
      },

      signature = { enabled = true }
    },
  },
}


================================================
FILE: nvim/lua/config/plugins/lsp.lua
================================================
return {
  {
    "neovim/nvim-lspconfig",
    dependencies = {
      'saghen/blink.cmp',
      {
        "folke/lazydev.nvim",
        opts = {
          library = {
            { path = "${3rd}/luv/library", words = { "vim%.uv" } },
          },
        },
      },
    },
    config = function()
      local capabilities = require('blink.cmp').get_lsp_capabilities()
      require("lspconfig").lua_ls.setup { capabilites = capabilities }

      vim.api.nvim_create_autocmd('LspAttach', {
        callback = function(args)
          local c = vim.lsp.get_client_by_id(args.data.client_id)
          if not c then return end

          if vim.bo.filetype == "lua" then
            -- Format the current buffer on save
            vim.api.nvim_create_autocmd('BufWritePre', {
              buffer = args.buf,
              callback = function()
                vim.lsp.buf.format({ bufnr = args.buf, id = c.id })
              end,
            })
          end
        end,
      })
    end,
  }
}


================================================
FILE: nvim/lua/config/plugins/mini.lua
================================================
-- lua/custom/plugins/mini.lua
return {
	{
		'echasnovski/mini.nvim',
		enabled = true,
		config = function()
			local statusline = require 'mini.statusline'
			statusline.setup { use_icons = true }
		end
	},
}


================================================
FILE: nvim/lua/config/plugins/oil.lua
================================================
return {
  {
    'stevearc/oil.nvim',
    ---@module 'oil'
    ---@type oil.SetupOpts
    opts = {},
    -- Optional dependencies
    dependencies = { { "echasnovski/mini.icons", opts = {} } },
    -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
  }
}


================================================
FILE: nvim/lua/config/plugins/telescope.lua
================================================
return {
  {
    'nvim-telescope/telescope.nvim',
    tag = '0.1.8',
    dependencies = {
      'nvim-lua/plenary.nvim',
      { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
    },
    config = function()
      require('telescope').setup {
        pickers = {
          find_files = {
            theme = "ivy"
          }
        },
        extensions = {
          fzf = {}
        }
      }

      require('telescope').load_extension('fzf')

      vim.keymap.set("n", "<space>fh", require('telescope.builtin').help_tags)
      vim.keymap.set("n", "<space>fd", require('telescope.builtin').find_files)
      vim.keymap.set("n", "<space>en", function()
        require('telescope.builtin').find_files {
          cwd = vim.fn.stdpath("config")
        }
      end)
      vim.keymap.set("n", "<space>ep", function()
        require('telescope.builtin').find_files {
          cwd = vim.fs.joinpath(vim.fn.stdpath("data"), "lazy")
        }
      end)

      require "config.telescope.multigrep".setup()
    end
  }
}


================================================
FILE: nvim/lua/config/plugins/treesitter.lua
================================================
return {
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require'nvim-treesitter.configs'.setup {
	ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" },
	auto_install = false,
	highlight = {
	  enable = true,
	  disable = function(lang, buf)
	    local max_filesize = 100 * 1024 -- 100 KB
	    local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
	    if ok and stats and stats.size > max_filesize then
	      return true
	    end
	  end,
	  additional_vim_regex_highlighting = false,
	},
      }
    end,
  }
}


================================================
FILE: nvim/lua/config/telescope/multigrep.lua
================================================
local pickers = require "telescope.pickers"
local finders = require "telescope.finders"
local make_entry = require "telescope.make_entry"
local conf = require "telescope.config".values

local M = {}

local live_multigrep = function(opts)
  opts = opts or {}
  opts.cwd = opts.cwd or vim.uv.cwd()

  local finder = finders.new_async_job {
    command_generator = function(prompt)
      if not prompt or prompt == "" then
        return nil
      end

      local pieces = vim.split(prompt, "  ")
      local args = { "rg" }
      if pieces[1] then
        table.insert(args, "-e")
        table.insert(args, pieces[1])
      end

      if pieces[2] then
        table.insert(args, "-g")
        table.insert(args, pieces[2])
      end

      ---@diagnostic disable-next-line: deprecated
      return vim.tbl_flatten {
        args,
        { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" },
      }
    end,
    entry_maker = make_entry.gen_from_vimgrep(opts),
    cwd = opts.cwd,
  }

  pickers.new(opts, {
    debounce = 100,
    prompt_title = "Multi Grep",
    finder = finder,
    previewer = conf.grep_previewer(opts),
    sorter = require("telescope.sorters").empty(),
  }):find()
end

M.setup = function()
  vim.keymap.set("n", "<leader>fg", live_multigrep)
end

return M


================================================
FILE: nvim/plugin/floaterminal.lua
================================================
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")

local state = {
  floating = {
    buf = -1,
    win = -1,
  }
}

local function create_floating_window(opts)
  opts = opts or {}
  local width = opts.width or math.floor(vim.o.columns * 0.8)
  local height = opts.height or math.floor(vim.o.lines * 0.8)

  -- Calculate the position to center the window
  local col = math.floor((vim.o.columns - width) / 2)
  local row = math.floor((vim.o.lines - height) / 2)

  -- Create a buffer
  local buf = nil
  if vim.api.nvim_buf_is_valid(opts.buf) then
    buf = opts.buf
  else
    buf = vim.api.nvim_create_buf(false, true) -- No file, scratch buffer
  end

  -- Define window configuration
  local win_config = {
    relative = "editor",
    width = width,
    height = height,
    col = col,
    row = row,
    style = "minimal", -- No borders or extra UI elements
    border = "rounded",
  }

  -- Create the floating window
  local win = vim.api.nvim_open_win(buf, true, win_config)

  return { buf = buf, win = win }
end

local toggle_terminal = function()
  if not vim.api.nvim_win_is_valid(state.floating.win) then
    state.floating = create_floating_window { buf = state.floating.buf }
    if vim.bo[state.floating.buf].buftype ~= "terminal" then
      vim.cmd.terminal()
    end
  else
    vim.api.nvim_win_hide(state.floating.win)
  end
end

-- Example usage:
-- Create a floating window with default dimensions
vim.api.nvim_create_user_command("Floaterminal", toggle_terminal, {})


================================================
FILE: nvim/plugin/menu.lua
================================================
vim.cmd [[
  aunmenu PopUp
  anoremenu PopUp.Inspect     <cmd>Inspect<CR>
  amenu PopUp.-1-             <NOP>
  anoremenu PopUp.Definition  <cmd>lua vim.lsp.buf.definition()<CR>
  anoremenu PopUp.References  <cmd>Telescope lsp_references<CR>
  nnoremenu PopUp.Back        <C-t>
  amenu PopUp.-2-             <NOP>
  amenu     PopUp.URL         gx
]]

local group = vim.api.nvim_create_augroup("nvim_popupmenu", { clear = true })
vim.api.nvim_create_autocmd("MenuPopup", {
  pattern = "*",
  group = group,
  desc = "Custom PopUp Setup",
  callback = function()
    vim.cmd [[
      amenu disable PopUp.Definition
      amenu disable PopUp.References
      amenu disable PopUp.URL
    ]]

    if vim.lsp.get_clients({ bufnr = 0 })[1] then
      vim.cmd [[
        amenu enable PopUp.Definition
        amenu enable PopUp.References
      ]]
    end

    local urls = require("vim.ui")._get_urls()
    if vim.startswith(urls[1], "http") then
      vim.cmd [[amenu enable PopUp.URL]]
    end
  end,
})
-- TODO: Add autocoommand
Download .txt
gitextract_ro4vkjfw/

├── 01 - Introduction/
│   └── 01 - Introduction.md
├── 02 - Tutor and Modal Editing/
│   └── 02 - Tutor and Modal Editing.md
├── 03 - Lua Crash Course/
│   ├── 03 - Lua Crash Course.md
│   └── init.lua
├── 04 - Package Manager/
│   ├── Package Manager.md
│   └── init.lua
├── Makefile
├── README.md
├── XX - oil/
│   ├── Oil.md
│   └── config/
│       ├── init.lua
│       ├── lazy-lock.json
│       └── lua/
│           └── config/
│               ├── lazy.lua
│               └── plugins/
│                   ├── mini.lua
│                   └── oil.lua
└── nvim/
    ├── after/
    │   └── ftplugin/
    │       └── lua.lua
    ├── init.lua
    ├── lazy-lock.json
    ├── lua/
    │   └── config/
    │       ├── lazy.lua
    │       ├── plugins/
    │       │   ├── completion.lua
    │       │   ├── lsp.lua
    │       │   ├── mini.lua
    │       │   ├── oil.lua
    │       │   ├── telescope.lua
    │       │   └── treesitter.lua
    │       └── telescope/
    │           └── multigrep.lua
    └── plugin/
        ├── floaterminal.lua
        └── menu.lua
Condensed preview — 27 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (27K chars).
[
  {
    "path": "01 - Introduction/01 - Introduction.md",
    "chars": 642,
    "preview": "# Introduction to Neovim\n\n## Why Do I Use Neovim?\n\n## Why Do I Use Neovim?\n\n- I find it very satisfying to make things j"
  },
  {
    "path": "02 - Tutor and Modal Editing/02 - Tutor and Modal Editing.md",
    "chars": 212,
    "preview": "# Vim Tutor: Explained\n\n## First\n\n- You have to actually practice\n- Don't just listen to me\n\n## How to practice?\n\nOpen N"
  },
  {
    "path": "03 - Lua Crash Course/03 - Lua Crash Course.md",
    "chars": 5536,
    "preview": "# Lua Crash Course\n\n## Table of Contents\n\n- Comments\n- Variables\n- Control Flow\n- Modules\n- Functions\n- Metatables\n- Bon"
  },
  {
    "path": "03 - Lua Crash Course/init.lua",
    "chars": 541,
    "preview": "-- Day 3\nprint(\"advent of neovim\")\n\nvim.keymap.set(\"n\", \"<space><space>x\", \"<cmd>source %<CR>\")\nvim.keymap.set(\"n\", \"<sp"
  },
  {
    "path": "04 - Package Manager/Package Manager.md",
    "chars": 740,
    "preview": "# Package Manager\n\n## Package Manager\n\nGoing to use `lazy.nvim`\n- https://lazy.folke.io/installation\n\nNOTE: which is dif"
  },
  {
    "path": "04 - Package Manager/init.lua",
    "chars": 565,
    "preview": "print(\"advent of neovim\")\nprint(\"advent of neovim\")\n\n\nvim.keymap.set(\"n\", \"<space><space>x\", \"<cmd>source %<CR>\")\nvim.ke"
  },
  {
    "path": "Makefile",
    "chars": 76,
    "preview": "update:\n\trm -rf ./nvim\n\tmkdir nvim\n\tcp -rf ~/.config/nvimexample/* ./nvim/\n\n"
  },
  {
    "path": "README.md",
    "chars": 1082,
    "preview": "# Advent of `nvim`\n\nCheck the config in: `./nvim/`\n- This should be versioned roughly by day, so you can go back and che"
  },
  {
    "path": "XX - oil/Oil.md",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "XX - oil/config/init.lua",
    "chars": 562,
    "preview": "print(\"advent of neovim\")\n\nrequire(\"config.lazy\")\n\nvim.keymap.set(\"n\", \"<space><space>x\", \"<cmd>source %<CR>\")\nvim.keyma"
  },
  {
    "path": "XX - oil/config/lazy-lock.json",
    "chars": 282,
    "preview": "{\n  \"lazy.nvim\": { \"branch\": \"main\", \"commit\": \"7967abe55752aa90532e6bb4bd4663fe27a264cb\" },\n  \"mini.nvim\": { \"branch\": "
  },
  {
    "path": "XX - oil/config/lua/config/lazy.lua",
    "chars": 1052,
    "preview": "-- Bootstrap lazy.nvim\nlocal lazypath = vim.fn.stdpath(\"data\") .. \"/lazy/lazy.nvim\"\nif not (vim.uv or vim.loop).fs_stat("
  },
  {
    "path": "XX - oil/config/lua/config/plugins/mini.lua",
    "chars": 252,
    "preview": "-- lua/custom/plugins/mini.lua\nreturn {\n    {\n        'echasnovski/mini.nvim',\n\tenabled = true,\n        config = functio"
  },
  {
    "path": "XX - oil/config/lua/config/plugins/oil.lua",
    "chars": 510,
    "preview": "return {\n\t{\n\t\t\"stevearc/oil.nvim\",\n\t\tdependencies = { \"nvim-tree/nvim-web-devicons\" },\n\t\tconfig = function()\n\t\t\trequire("
  },
  {
    "path": "nvim/after/ftplugin/lua.lua",
    "chars": 90,
    "preview": "local set = vim.opt_local\n\nset.shiftwidth = 2\nset.number = true\nset.relativenumber = true\n"
  },
  {
    "path": "nvim/init.lua",
    "chars": 1528,
    "preview": "print(\"advent of neovim\")\n\nrequire(\"config.lazy\")\n\nvim.opt.shiftwidth = 4\nvim.opt.clipboard = \"unnamedplus\"\nvim.opt.numb"
  },
  {
    "path": "nvim/lazy-lock.json",
    "chars": 1248,
    "preview": "{\n  \"blink.cmp\": { \"branch\": \"main\", \"commit\": \"ae5a4ce8f7e519e49de7ae6fcadd74547f820a52\" },\n  \"friendly-snippets\": { \"b"
  },
  {
    "path": "nvim/lua/config/lazy.lua",
    "chars": 1228,
    "preview": "-- Bootstrap lazy.nvim\nlocal lazypath = vim.fn.stdpath(\"data\") .. \"/lazy/lazy.nvim\"\nif not (vim.uv or vim.loop).fs_stat("
  },
  {
    "path": "nvim/lua/config/plugins/completion.lua",
    "chars": 322,
    "preview": "return {\n  {\n    'saghen/blink.cmp',\n    dependencies = 'rafamadriz/friendly-snippets',\n\n    version = 'v0.*',\n\n    opts"
  },
  {
    "path": "nvim/lua/config/plugins/lsp.lua",
    "chars": 997,
    "preview": "return {\n  {\n    \"neovim/nvim-lspconfig\",\n    dependencies = {\n      'saghen/blink.cmp',\n      {\n        \"folke/lazydev."
  },
  {
    "path": "nvim/lua/config/plugins/mini.lua",
    "chars": 211,
    "preview": "-- lua/custom/plugins/mini.lua\nreturn {\n\t{\n\t\t'echasnovski/mini.nvim',\n\t\tenabled = true,\n\t\tconfig = function()\n\t\t\tlocal s"
  },
  {
    "path": "nvim/lua/config/plugins/oil.lua",
    "chars": 292,
    "preview": "return {\n  {\n    'stevearc/oil.nvim',\n    ---@module 'oil'\n    ---@type oil.SetupOpts\n    opts = {},\n    -- Optional dep"
  },
  {
    "path": "nvim/lua/config/plugins/telescope.lua",
    "chars": 1033,
    "preview": "return {\n  {\n    'nvim-telescope/telescope.nvim',\n    tag = '0.1.8',\n    dependencies = {\n      'nvim-lua/plenary.nvim',"
  },
  {
    "path": "nvim/lua/config/plugins/treesitter.lua",
    "chars": 621,
    "preview": "return {\n  {\n    \"nvim-treesitter/nvim-treesitter\",\n    build = \":TSUpdate\",\n    config = function()\n      require'nvim-"
  },
  {
    "path": "nvim/lua/config/telescope/multigrep.lua",
    "chars": 1329,
    "preview": "local pickers = require \"telescope.pickers\"\nlocal finders = require \"telescope.finders\"\nlocal make_entry = require \"tele"
  },
  {
    "path": "nvim/plugin/floaterminal.lua",
    "chars": 1489,
    "preview": "vim.keymap.set(\"t\", \"<esc><esc>\", \"<c-\\\\><c-n>\")\n\nlocal state = {\n  floating = {\n    buf = -1,\n    win = -1,\n  }\n}\n\nloca"
  },
  {
    "path": "nvim/plugin/menu.lua",
    "chars": 1025,
    "preview": "vim.cmd [[\n  aunmenu PopUp\n  anoremenu PopUp.Inspect     <cmd>Inspect<CR>\n  amenu PopUp.-1-             <NOP>\n  anoremen"
  }
]

About this extraction

This page contains the full source code of the tjdevries/advent-of-nvim GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 27 files (22.9 KB), approximately 7.8k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!