Init
This commit is contained in:
1
config/nvim/.gitignore
vendored
Normal file
1
config/nvim/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
lazy-lock.json
|
||||||
117
config/nvim/README.md
Normal file
117
config/nvim/README.md
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
# Neovim Keybinds Documentation
|
||||||
|
|
||||||
|
This document provides a simple and organized overview of all the custom keybinds defined in my Neovim configuration.
|
||||||
|
|
||||||
|
## General Keybinds
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|------|-----------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | `<leader>cd` | Open Ex mode (`:Ex`) |
|
||||||
|
| `n` | `J` | Join lines while keeping the cursor in place |
|
||||||
|
| `n` | `<C-d>` | Scroll half-page down and keep the cursor centered |
|
||||||
|
| `n` | `<C-u>` | Scroll half-page up and keep the cursor centered |
|
||||||
|
| `n` | `n` | Move to next search result and keep it centered |
|
||||||
|
| `n` | `N` | Move to previous search result and keep it centered |
|
||||||
|
| `n` | `Q` | Disable Ex mode |
|
||||||
|
| `n` | `<C-k>` | Jump to next quickfix entry and keep it centered |
|
||||||
|
| `n` | `<C-j>` | Jump to previous quickfix entry and keep it centered |
|
||||||
|
| `n` | `<leader>k` | Jump to next location entry and keep it centered |
|
||||||
|
| `n` | `<leader>j` | Jump to previous location entry and keep it centered |
|
||||||
|
| `i` | `<C-c>` | Exit insert mode (acts like `Esc`) |
|
||||||
|
| `n` | `<leader>x` | Make current file executable (`chmod +x`) |
|
||||||
|
| `n` | `<leader>u` | Toggle Undotree |
|
||||||
|
| `n` | `<leader>rl` | Reload the Neovim config (`~/.config/nvim/init.lua`) |
|
||||||
|
| `n` | `<leader><leader>` | Source the current file (`:so`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Visual Mode Keybinds
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|------|-----------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `v` | `J` | Move selected block down |
|
||||||
|
| `v` | `K` | Move selected block up |
|
||||||
|
| `x` | `<leader>p` | Paste without overwriting clipboard |
|
||||||
|
| `v` | `<leader>y` | Yank into system clipboard (even on SSH) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Linting and Formatting
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|------|-----------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | `<leader>cc` | Run `php-cs-fixer` to lint and format PHP files |
|
||||||
|
| `n` | `<F3>` | Format code (`LSP`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Telescope Keybinds
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|------|-----------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | `<leader>ff` | Find files |
|
||||||
|
| `n` | `<leader>fg` | Find git-tracked files |
|
||||||
|
| `n` | `<leader>fo` | Open recent files |
|
||||||
|
| `n` | `<leader>fq` | Open quickfix list |
|
||||||
|
| `n` | `<leader>fh` | Open help tags |
|
||||||
|
| `n` | `<leader>fb` | Open buffer list |
|
||||||
|
| `n` | `<leader>fs` | Grep current string |
|
||||||
|
| `n` | `<leader>fc` | Grep instances of the current file name without the extension |
|
||||||
|
| `n` | `<leader>fi` | Find files in Neovim configuration directory (`~/.config/nvim/`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Harpoon Integration
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|------|-----------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | `<leader>a` | Add current file to Harpoon list |
|
||||||
|
| `n` | `<C-e>` | Toggle Harpoon quick menu |
|
||||||
|
| `n` | `<leader>fl` | Open Harpoon window with Telescope |
|
||||||
|
| `n` | `<C-p>` | Go to previous Harpoon mark |
|
||||||
|
| `n` | `<C-n>` | Go to next Harpoon mark |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## LSP Keybinds
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|-----------|------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | `K` | Show hover information |
|
||||||
|
| `n` | `gd` | Go to definition |
|
||||||
|
| `n` | `gD` | Go to declaration |
|
||||||
|
| `n` | `gi` | Go to implementation |
|
||||||
|
| `n` | `go` | Go to type definition |
|
||||||
|
| `n` | `gr` | Show references |
|
||||||
|
| `n` | `gs` | Show signature help |
|
||||||
|
| `n` | `gl` | Show diagnostics in a floating window |
|
||||||
|
| `n` | `<F2>` | Rename symbol |
|
||||||
|
| `n`, `x` | `<F3>` | Format code asynchronously |
|
||||||
|
| `n` | `<F4>` | Show code actions |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Miscellaneous
|
||||||
|
|
||||||
|
| Mode | Key | Action |
|
||||||
|
|------|-----------------|---------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | `<leader>dg` | Run `DogeGenerate` (comment documentation generation) |
|
||||||
|
| `n` | `<leader>s` | Replace all instances of the word under the cursor on the current line |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# LSP servers:
|
||||||
|
|
||||||
|
I am migrating my lsp config to /lua/plugins/lsp.lua because nvim v0.11 allows a very minimal debloated way to setup language server protocols.
|
||||||
|
|
||||||
|
Below is a running list of what and how to install the lsp's that are going to be configured in this build. I will avoid mason for now because I think its better to have full control over your system, and not outsource it to mason. Just uncommonet `return {` in /plugins/lsp.lua from the original lspconfig if you want to go that route.
|
||||||
|
|
||||||
|
1. { lua-language-server }
|
||||||
|
- refer to distro ( pacman -Ss lua-language-server )
|
||||||
|
2. { css-language-server --studio, html-language-server }
|
||||||
|
- npm install -g vscode-langservers-extracted
|
||||||
|
3. { intelephense }
|
||||||
|
- npm install -g intelephense
|
||||||
|
4. { typescript-language-server }
|
||||||
|
- npm install -g typescript-language-server typescript
|
||||||
|
|
||||||
2
config/nvim/after/ftplugin/goon.lua
Normal file
2
config/nvim/after/ftplugin/goon.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vim.bo.commentstring = "// %s"
|
||||||
|
vim.bo.comments = "s:/*,m: *,ex:*/,://"
|
||||||
12
config/nvim/after/ftplugin/hare.lua
Normal file
12
config/nvim/after/ftplugin/hare.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
local set = vim.opt_local
|
||||||
|
|
||||||
|
vim.bo.commentstring = "// %s"
|
||||||
|
vim.bo.comments = "s:/*,m: *,ex:*/,://"
|
||||||
|
|
||||||
|
set.shiftwidth = 4
|
||||||
|
set.tabstop = 4
|
||||||
|
set.softtabstop = 4
|
||||||
|
set.expandtab = true
|
||||||
|
|
||||||
|
set.number = true
|
||||||
|
set.relativenumber = true
|
||||||
9
config/nvim/after/ftplugin/jsonc.lua
Normal file
9
config/nvim/after/ftplugin/jsonc.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
local set = vim.opt_local
|
||||||
|
|
||||||
|
set.shiftwidth = 2
|
||||||
|
set.tabstop = 2
|
||||||
|
set.softtabstop = 2
|
||||||
|
set.expandtab = true
|
||||||
|
|
||||||
|
set.number = true
|
||||||
|
set.relativenumber = true
|
||||||
8
config/nvim/after/ftplugin/man.lua
Normal file
8
config/nvim/after/ftplugin/man.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
local set = vim.opt_local
|
||||||
|
set.number = true
|
||||||
|
set.relativenumber = true
|
||||||
|
set.number = true
|
||||||
|
set.relativenumber = false
|
||||||
|
set.wrap = true
|
||||||
|
set.linebreak = true
|
||||||
|
set.conceallevel = 0
|
||||||
8
config/nvim/after/ftplugin/nix.lua
Normal file
8
config/nvim/after/ftplugin/nix.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
local set = vim.opt_local
|
||||||
|
|
||||||
|
set.shiftwidth = 2
|
||||||
|
set.tabstop = 2
|
||||||
|
set.softtabstop = 2
|
||||||
|
set.expandtab = true
|
||||||
|
set.number = true
|
||||||
|
set.relativenumber = true
|
||||||
6
config/nvim/after/plugin/colors.lua
Normal file
6
config/nvim/after/plugin/colors.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
vim.cmd.colorscheme("tokyonight")
|
||||||
|
vim.cmd("hi Directory guibg=NONE")
|
||||||
|
vim.cmd("hi SignColumn guibg=NONE")
|
||||||
|
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||||
|
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||||
|
vim.api.nvim_set_hl(0, "LineNr", { bg = "none" })
|
||||||
33
config/nvim/after/plugin/completion.lua
Normal file
33
config/nvim/after/plugin/completion.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
local cmp = require("cmp")
|
||||||
|
require("cmp_nvim_lsp").setup()
|
||||||
|
cmp.register_source("path", require("cmp_path").new())
|
||||||
|
cmp.register_source("buffer", require("cmp_buffer"))
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
preselect = cmp.PreselectMode.Item,
|
||||||
|
completion = {
|
||||||
|
completeopt = "menu,menuone,noinsert",
|
||||||
|
autocomplete = { cmp.TriggerEvent.TextChanged },
|
||||||
|
},
|
||||||
|
window = { documentation = cmp.config.window.bordered() },
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||||||
|
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then cmp.select_next_item() else fallback() end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function()
|
||||||
|
if cmp.visible() then cmp.select_prev_item() end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
}),
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "buffer", keyword_length = 3 },
|
||||||
|
},
|
||||||
|
})
|
||||||
21
config/nvim/after/plugin/harpoon.lua
Normal file
21
config/nvim/after/plugin/harpoon.lua
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
local harpoon = require("harpoon")
|
||||||
|
harpoon:setup()
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
|
||||||
|
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
|
||||||
|
vim.keymap.set("n", "<C-p>", function() harpoon:list():prev() end)
|
||||||
|
vim.keymap.set("n", "<C-n>", function() harpoon:list():next() end)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>fl", function()
|
||||||
|
local conf = require("telescope.config").values
|
||||||
|
local themes = require("telescope.themes")
|
||||||
|
local file_paths = {}
|
||||||
|
for _, item in ipairs(harpoon:list().items) do
|
||||||
|
table.insert(file_paths, item.value)
|
||||||
|
end
|
||||||
|
require("telescope.pickers").new(themes.get_ivy({ prompt_title = "Working List" }), {
|
||||||
|
finder = require("telescope.finders").new_table({ results = file_paths }),
|
||||||
|
previewer = conf.file_previewer({}),
|
||||||
|
sorter = conf.generic_sorter({}),
|
||||||
|
}):find()
|
||||||
|
end, { desc = "Open harpoon window" })
|
||||||
2
config/nvim/after/plugin/one-liners.lua
Normal file
2
config/nvim/after/plugin/one-liners.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
require("lualine").setup({ options = { theme = "tokyonight" } })
|
||||||
|
require("nvim-highlight-colors").setup({})
|
||||||
34
config/nvim/after/plugin/telescope.lua
Normal file
34
config/nvim/after/plugin/telescope.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
local actions = require("telescope.actions")
|
||||||
|
require("telescope").setup({
|
||||||
|
defaults = {
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<C-k>"] = actions.move_selection_previous,
|
||||||
|
["<C-j>"] = actions.move_selection_next,
|
||||||
|
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local builtin = require("telescope.builtin")
|
||||||
|
vim.keymap.set("n", "<leader>ff", builtin.find_files)
|
||||||
|
vim.keymap.set("n", "<leader>fo", builtin.oldfiles)
|
||||||
|
vim.keymap.set("n", "<leader>fq", builtin.quickfix)
|
||||||
|
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
|
||||||
|
vim.keymap.set("n", "<leader>fm", function()
|
||||||
|
builtin.man_pages({ sections = { "ALL" } })
|
||||||
|
end, { desc = "Telescope man pages" })
|
||||||
|
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
|
||||||
|
vim.keymap.set("n", "<leader>fg", function()
|
||||||
|
builtin.grep_string({ search = vim.fn.input("Grep > ") })
|
||||||
|
end)
|
||||||
|
vim.keymap.set("n", "<leader>fc", function()
|
||||||
|
builtin.grep_string({ search = vim.fn.expand("%:t:r") })
|
||||||
|
end, { desc = "Find current file" })
|
||||||
|
vim.keymap.set("n", "<leader>fs", function()
|
||||||
|
builtin.grep_string({})
|
||||||
|
end, { desc = "Find current string" })
|
||||||
|
vim.keymap.set("n", "<leader>fi", function()
|
||||||
|
builtin.find_files({ cwd = "~/.config/nvim/" })
|
||||||
|
end)
|
||||||
6
config/nvim/after/plugin/treesitter.lua
Normal file
6
config/nvim/after/plugin/treesitter.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- Treesitter config lives in plugin/tonysitter.lua.
|
||||||
|
-- The only thing left here is the goon filetype mapping;
|
||||||
|
-- goon's parser is at ~/.local/share/nvim/site/parser/goon.so
|
||||||
|
-- and queries are at ~/.config/nvim/queries/goon/, both auto-loaded.
|
||||||
|
|
||||||
|
vim.filetype.add({ extension = { goon = "goon" } })
|
||||||
3
config/nvim/init.lua
Normal file
3
config/nvim/init.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
require("config.options")
|
||||||
|
require("config.keybinds")
|
||||||
|
require("manage").setup()
|
||||||
64
config/nvim/lua/config/keybinds.lua
Normal file
64
config/nvim/lua/config/keybinds.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
-- KEYBINDS
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.keymap.set("n", "<leader>cd", vim.cmd.Ex)
|
||||||
|
|
||||||
|
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- Alt Up/Down in vscode
|
||||||
|
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||||
|
|
||||||
|
vim.keymap.set("n", "J", "mzJ`z") -- Remap joining lines
|
||||||
|
vim.keymap.set("n", "<C-d>", "<C-d>zz") -- Keep cursor in place while moving up/down page
|
||||||
|
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||||
|
vim.keymap.set("n", "n", "nzzzv") -- center screen when looping search results
|
||||||
|
vim.keymap.set("n", "N", "Nzzzv")
|
||||||
|
|
||||||
|
-- paste and don't replace clipboard over deleted text
|
||||||
|
vim.keymap.set("x", "<leader>p", [["_dP]])
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>d", [["_d]])
|
||||||
|
|
||||||
|
|
||||||
|
-- sometimes in insert mode, control-c doesn't exactly work like escape
|
||||||
|
vim.keymap.set("i", "<C-c>", "<Esc>")
|
||||||
|
|
||||||
|
-- add binds for Control J/K to scroll thru quickfix list
|
||||||
|
vim.keymap.set("n", "<C-j>", "<cmd>cnext<CR>zz")
|
||||||
|
vim.keymap.set("n", "<C-k>", "<cmd>cprev<CR>zz")
|
||||||
|
|
||||||
|
-- What the heck is Ex mode?
|
||||||
|
vim.keymap.set("n", "Q", "<nop>")
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||||
|
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
||||||
|
|
||||||
|
|
||||||
|
-- lint / format php files for LC
|
||||||
|
vim.keymap.set("n", "<leader>cc", "<cmd>!php-cs-fixer fix % --using-cache=no<cr>")
|
||||||
|
|
||||||
|
-- Replace all instances of whatever is under cursor (on line)
|
||||||
|
vim.keymap.set("n", "<leader>s", [[:s/\<<C-r><C-w>\>//gI<Left><Left><Left>]])
|
||||||
|
|
||||||
|
-- make file executable
|
||||||
|
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||||
|
|
||||||
|
-- yank into clipboard even if on ssh
|
||||||
|
vim.keymap.set('n', '<leader>y', '<Plug>OSCYankOperator')
|
||||||
|
vim.keymap.set('v', '<leader>y', '<Plug>OSCYankVisual')
|
||||||
|
|
||||||
|
-- reload without exiting vim
|
||||||
|
vim.keymap.set("n", "<leader>rl", "<cmd>source ~/.config/nvim/init.lua<cr>")
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||||
|
|
||||||
|
-- Quickfix list stuff
|
||||||
|
vim.keymap.set("n", "<leader>cl", ":cclose<CR>", { silent = true })
|
||||||
|
vim.keymap.set("n", "<leader>co", ":copen<CR>", { silent = true })
|
||||||
|
vim.keymap.set("n", "<leader>cn", ":cnext<CR>zz")
|
||||||
|
vim.keymap.set("n", "<leader>cp", ":cprev<CR>zz")
|
||||||
|
vim.keymap.set("n", "<leader>li", ":checkhealth vim.lsp<CR>", { desc = "LSP Info" })
|
||||||
|
|
||||||
|
-- run make in current working directory
|
||||||
|
vim.keymap.set("n", "<leader>mm", "<cmd>make<CR>")
|
||||||
|
|
||||||
|
-- source file
|
||||||
|
vim.keymap.set("n", "<leader><leader>", function()
|
||||||
|
vim.cmd("so")
|
||||||
|
end)
|
||||||
55
config/nvim/lua/config/options.lua
Normal file
55
config/nvim/lua/config/options.lua
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
-- OPTIONS
|
||||||
|
local set = vim.opt
|
||||||
|
|
||||||
|
--line nums
|
||||||
|
set.relativenumber = true
|
||||||
|
set.number = true
|
||||||
|
|
||||||
|
-- indentation and tabs
|
||||||
|
set.tabstop = 4
|
||||||
|
set.shiftwidth = 4
|
||||||
|
set.autoindent = true
|
||||||
|
set.expandtab = true
|
||||||
|
|
||||||
|
-- search settings
|
||||||
|
set.ignorecase = true
|
||||||
|
set.smartcase = true
|
||||||
|
|
||||||
|
-- appearance
|
||||||
|
set.termguicolors = true
|
||||||
|
set.background = "dark"
|
||||||
|
set.signcolumn = "yes"
|
||||||
|
|
||||||
|
-- cursor line
|
||||||
|
set.cursorline = true
|
||||||
|
|
||||||
|
-- 80th column
|
||||||
|
set.colorcolumn = "80"
|
||||||
|
|
||||||
|
-- clipboard
|
||||||
|
set.clipboard:append("unnamedplus")
|
||||||
|
|
||||||
|
-- backspace
|
||||||
|
set.backspace = "indent,eol,start"
|
||||||
|
|
||||||
|
-- split windows
|
||||||
|
set.splitbelow = true
|
||||||
|
set.splitright = true
|
||||||
|
|
||||||
|
-- dw/diw/ciw works on full-word
|
||||||
|
set.iskeyword:append("-")
|
||||||
|
|
||||||
|
-- keep cursor at least 8 rows from top/bot
|
||||||
|
set.scrolloff = 8
|
||||||
|
|
||||||
|
-- undo dir settings
|
||||||
|
set.swapfile = false
|
||||||
|
set.backup = false
|
||||||
|
set.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||||
|
set.undofile = true
|
||||||
|
|
||||||
|
-- incremental search
|
||||||
|
set.incsearch = true
|
||||||
|
|
||||||
|
-- faster cursor hold
|
||||||
|
set.updatetime = 50
|
||||||
36
config/nvim/lua/manage.lua
Normal file
36
config/nvim/lua/manage.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
local M = {}
|
||||||
|
local plug_dir = vim.fn.stdpath("data") .. "/plugins"
|
||||||
|
|
||||||
|
local function ensure(spec)
|
||||||
|
local repo = type(spec) == "string" and spec or spec[1]
|
||||||
|
local name = repo:match(".+/(.+)$")
|
||||||
|
local path = plug_dir .. "/" .. name
|
||||||
|
|
||||||
|
if not vim.uv.fs_stat(path) then
|
||||||
|
vim.fn.mkdir(plug_dir, "p")
|
||||||
|
local cmd = { "git", "clone", "--depth=1" }
|
||||||
|
if spec.branch then
|
||||||
|
table.insert(cmd, "-b")
|
||||||
|
table.insert(cmd, spec.branch)
|
||||||
|
end
|
||||||
|
table.insert(cmd, "https://github.com/" .. repo)
|
||||||
|
table.insert(cmd, path)
|
||||||
|
print("Installing " .. name .. "...")
|
||||||
|
vim.fn.system(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.rtp:prepend(path)
|
||||||
|
vim.opt.rtp:append(path .. "/after")
|
||||||
|
local lua_path = path .. "/lua"
|
||||||
|
if vim.uv.fs_stat(lua_path) then
|
||||||
|
package.path = package.path .. ";" .. lua_path .. "/?.lua;" .. lua_path .. "/?/init.lua"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
for _, spec in ipairs(require("plugin-list")) do
|
||||||
|
ensure(spec)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
17
config/nvim/lua/plugin-list.lua
Normal file
17
config/nvim/lua/plugin-list.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
return {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
{ "ThePrimeagen/harpoon", branch = "harpoon2" },
|
||||||
|
"folke/tokyonight.nvim",
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
"brenoprata10/nvim-highlight-colors",
|
||||||
|
"tpope/vim-fugitive",
|
||||||
|
"mbbill/undotree",
|
||||||
|
"ojroques/vim-oscyank",
|
||||||
|
"captbaritone/better-indent-support-for-php-with-html",
|
||||||
|
}
|
||||||
BIN
config/nvim/parser/c.so
Executable file
BIN
config/nvim/parser/c.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/go.so
Executable file
BIN
config/nvim/parser/go.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/javascript.so
Executable file
BIN
config/nvim/parser/javascript.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/lua.so
Executable file
BIN
config/nvim/parser/lua.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/nix.so
Executable file
BIN
config/nvim/parser/nix.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/php.so
Executable file
BIN
config/nvim/parser/php.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/rust.so
Executable file
BIN
config/nvim/parser/rust.so
Executable file
Binary file not shown.
BIN
config/nvim/parser/zig.so
Executable file
BIN
config/nvim/parser/zig.so
Executable file
Binary file not shown.
224
config/nvim/plugin/docgen.lua
Normal file
224
config/nvim/plugin/docgen.lua
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- C/kernel-doc style: /** ... @param: ... Return: ... */
|
||||||
|
local function generate_c_doc(bufnr, row, line)
|
||||||
|
-- strip static/inline/extern prefixes
|
||||||
|
local stripped = line:gsub("^%s*static%s+", ""):gsub("^%s*inline%s+", ""):gsub("^%s*extern%s+", "")
|
||||||
|
|
||||||
|
-- match: type *func_name(params) or type* func_name(params)
|
||||||
|
local ret, name, params = stripped:match("^%s*([%w_]+%s*%**)%s*([%w_]+)%s*%((.*)%)%s*{?%s*$")
|
||||||
|
if not name then
|
||||||
|
return nil, "No C function signature found on current line"
|
||||||
|
end
|
||||||
|
|
||||||
|
local doc = { "/**", " * " .. name .. "() - " }
|
||||||
|
|
||||||
|
-- parse parameters
|
||||||
|
if params and params:match("%S") and not params:match("^%s*void%s*$") then
|
||||||
|
for param in params:gmatch("([^,]+)") do
|
||||||
|
local pname = param:match("([%w_]+)%s*$")
|
||||||
|
or param:match("%*%s*([%w_]+)")
|
||||||
|
or param:match("([%w_]+)%s*%[")
|
||||||
|
if pname then
|
||||||
|
table.insert(doc, " * @" .. pname .. ": ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(doc, " *")
|
||||||
|
|
||||||
|
-- add Return: if not void
|
||||||
|
ret = ret and ret:gsub("%s+", " "):gsub("^%s*", ""):gsub("%s*$", "") or ""
|
||||||
|
if ret ~= "void" and ret ~= "" then
|
||||||
|
table.insert(doc, " * Return: ")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(doc, " */")
|
||||||
|
return doc, nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Go style: // FunctionName does something.
|
||||||
|
local function generate_go_doc(bufnr, row, line)
|
||||||
|
-- match: func (receiver) name(params) return or func name(params) return
|
||||||
|
local name, params, ret
|
||||||
|
|
||||||
|
-- method with receiver: func (r *Receiver) Name(params) return
|
||||||
|
name, params, ret = line:match("^%s*func%s+%([^)]+%)%s+([%w_]+)%s*%((.-)%)%s*(.-)%s*{?%s*$")
|
||||||
|
|
||||||
|
-- regular function: func Name(params) return
|
||||||
|
if not name then
|
||||||
|
name, params, ret = line:match("^%s*func%s+([%w_]+)%s*%((.-)%)%s*(.-)%s*{?%s*$")
|
||||||
|
end
|
||||||
|
|
||||||
|
if not name then
|
||||||
|
return nil, "No Go function signature found on current line"
|
||||||
|
end
|
||||||
|
|
||||||
|
local doc = { "// " .. name .. " " }
|
||||||
|
|
||||||
|
-- add parameter hints if present
|
||||||
|
if params and params:match("%S") then
|
||||||
|
local param_names = {}
|
||||||
|
for param in params:gmatch("([^,]+)") do
|
||||||
|
-- Go params: name type or name, name2 type
|
||||||
|
local pname = param:match("^%s*([%w_]+)")
|
||||||
|
if pname then
|
||||||
|
table.insert(param_names, pname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #param_names > 0 then
|
||||||
|
table.insert(doc, "//")
|
||||||
|
table.insert(doc, "// Parameters:")
|
||||||
|
for _, pname in ipairs(param_names) do
|
||||||
|
table.insert(doc, "// - " .. pname .. ": ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add return hint if present
|
||||||
|
ret = ret and ret:gsub("^%s*", ""):gsub("%s*$", "") or ""
|
||||||
|
if ret ~= "" and ret ~= "error" then
|
||||||
|
table.insert(doc, "//")
|
||||||
|
table.insert(doc, "// Returns: ")
|
||||||
|
end
|
||||||
|
|
||||||
|
return doc, nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Rust style: /// Description
|
||||||
|
local function generate_rust_doc(bufnr, row, line)
|
||||||
|
-- match: fn name(params) -> return or pub fn name...
|
||||||
|
local name, params, ret = line:match("^%s*pub%s+fn%s+([%w_]+)%s*%((.-)%)%s*%->%s*(.-)%s*{?%s*$")
|
||||||
|
if not name then
|
||||||
|
name, params, ret = line:match("^%s*fn%s+([%w_]+)%s*%((.-)%)%s*%->%s*(.-)%s*{?%s*$")
|
||||||
|
end
|
||||||
|
if not name then
|
||||||
|
name, params = line:match("^%s*pub%s+fn%s+([%w_]+)%s*%((.-)%)%s*{?%s*$")
|
||||||
|
end
|
||||||
|
if not name then
|
||||||
|
name, params = line:match("^%s*fn%s+([%w_]+)%s*%((.-)%)%s*{?%s*$")
|
||||||
|
end
|
||||||
|
|
||||||
|
if not name then
|
||||||
|
return nil, "No Rust function signature found on current line"
|
||||||
|
end
|
||||||
|
|
||||||
|
local doc = { "/// " }
|
||||||
|
|
||||||
|
-- add parameter hints if present
|
||||||
|
if params and params:match("%S") then
|
||||||
|
local param_names = {}
|
||||||
|
for param in params:gmatch("([^,]+)") do
|
||||||
|
local pname = param:match("^%s*([%w_]+)%s*:")
|
||||||
|
if pname and pname ~= "self" and pname ~= "&self" and pname ~= "&mut" then
|
||||||
|
table.insert(param_names, pname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #param_names > 0 then
|
||||||
|
table.insert(doc, "///")
|
||||||
|
table.insert(doc, "/// # Arguments")
|
||||||
|
table.insert(doc, "///")
|
||||||
|
for _, pname in ipairs(param_names) do
|
||||||
|
table.insert(doc, "/// * `" .. pname .. "` - ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add return hint if present
|
||||||
|
ret = ret and ret:gsub("^%s*", ""):gsub("%s*$", "") or ""
|
||||||
|
if ret ~= "" then
|
||||||
|
table.insert(doc, "///")
|
||||||
|
table.insert(doc, "/// # Returns")
|
||||||
|
table.insert(doc, "///")
|
||||||
|
table.insert(doc, "/// ")
|
||||||
|
end
|
||||||
|
|
||||||
|
return doc, nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Python style: """docstring"""
|
||||||
|
local function generate_python_doc(bufnr, row, line)
|
||||||
|
local name, params = line:match("^%s*def%s+([%w_]+)%s*%((.-)%)%s*:?%s*$")
|
||||||
|
if not name then
|
||||||
|
name, params = line:match("^%s*async%s+def%s+([%w_]+)%s*%((.-)%)%s*:?%s*$")
|
||||||
|
end
|
||||||
|
|
||||||
|
if not name then
|
||||||
|
return nil, "No Python function signature found on current line"
|
||||||
|
end
|
||||||
|
|
||||||
|
local indent = line:match("^(%s*)") or ""
|
||||||
|
local doc = { indent .. ' """' }
|
||||||
|
|
||||||
|
-- parse parameters
|
||||||
|
if params and params:match("%S") then
|
||||||
|
local param_names = {}
|
||||||
|
for param in params:gmatch("([^,]+)") do
|
||||||
|
local pname = param:match("^%s*([%w_]+)")
|
||||||
|
if pname and pname ~= "self" and pname ~= "cls" then
|
||||||
|
table.insert(param_names, pname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #param_names > 0 then
|
||||||
|
table.insert(doc, indent .. "")
|
||||||
|
table.insert(doc, indent .. " Args:")
|
||||||
|
for _, pname in ipairs(param_names) do
|
||||||
|
table.insert(doc, indent .. " " .. pname .. ": ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(doc, indent .. "")
|
||||||
|
table.insert(doc, indent .. " Returns:")
|
||||||
|
table.insert(doc, indent .. " ")
|
||||||
|
table.insert(doc, indent .. ' """')
|
||||||
|
|
||||||
|
return doc, nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- filetype to generator mapping
|
||||||
|
local generators = {
|
||||||
|
c = generate_c_doc,
|
||||||
|
cpp = generate_c_doc,
|
||||||
|
h = generate_c_doc,
|
||||||
|
go = generate_go_doc,
|
||||||
|
rust = generate_rust_doc,
|
||||||
|
python = generate_python_doc,
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.generate_doc()
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
|
local line = vim.api.nvim_buf_get_lines(bufnr, row - 1, row, false)[1]
|
||||||
|
local ft = vim.bo[bufnr].filetype
|
||||||
|
|
||||||
|
local generator = generators[ft]
|
||||||
|
if not generator then
|
||||||
|
vim.notify("No doc generator for filetype: " .. ft, vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local doc, err = generator(bufnr, row, line)
|
||||||
|
if err then
|
||||||
|
vim.notify(err, vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, row - 1, row - 1, false, doc)
|
||||||
|
|
||||||
|
-- position cursor at first empty description spot
|
||||||
|
local cursor_row = row
|
||||||
|
local cursor_col = #doc[1]
|
||||||
|
for i, docline in ipairs(doc) do
|
||||||
|
if docline:match("%s$") or docline:match(":%s*$") or docline:match("%-%s*$") then
|
||||||
|
cursor_row = row + i - 1
|
||||||
|
cursor_col = #docline
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_win_set_cursor(0, { cursor_row, cursor_col })
|
||||||
|
vim.cmd("startinsert!")
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>dg", M.generate_doc)
|
||||||
55
config/nvim/plugin/flterm.lua
Normal file
55
config/nvim/plugin/flterm.lua
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
-- Remap leaving 'terminal mode' to double tap esc
|
||||||
|
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
|
||||||
|
|
||||||
|
local state = {
|
||||||
|
floating = {
|
||||||
|
buf = -1,
|
||||||
|
win = -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function open_floating_terminal(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)
|
||||||
|
|
||||||
|
local row = math.floor((vim.o.lines - height) / 2)
|
||||||
|
local col = math.floor((vim.o.columns - width) / 2)
|
||||||
|
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
if not buf then
|
||||||
|
error("Failed to create buffer")
|
||||||
|
end
|
||||||
|
|
||||||
|
local win = vim.api.nvim_open_win(buf, true, {
|
||||||
|
relative = 'editor',
|
||||||
|
width = width,
|
||||||
|
height = height,
|
||||||
|
row = row,
|
||||||
|
col = col,
|
||||||
|
style = 'minimal',
|
||||||
|
border = 'rounded',
|
||||||
|
})
|
||||||
|
|
||||||
|
return { buf = buf, win = win }
|
||||||
|
end
|
||||||
|
|
||||||
|
local toggle_terminal = function()
|
||||||
|
if not vim.api.nvim_win_is_valid(state.floating.win) then
|
||||||
|
state.floating = open_floating_terminal({ buf = state.floating.buf });
|
||||||
|
if vim.bo[state.floating.buf].buftype ~= "terminal" then
|
||||||
|
vim.cmd.terminal()
|
||||||
|
vim.cmd("startinsert!")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
vim.api.nvim_win_hide(state.floating.win)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("Flterm", toggle_terminal, {})
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>ft', [[:Flterm<CR>]], { noremap = true, silent = true })
|
||||||
283
config/nvim/plugin/lsp.lua
Normal file
283
config/nvim/plugin/lsp.lua
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
vim.lsp.config('*', {
|
||||||
|
root_markers = { '.git' },
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = true,
|
||||||
|
severity_sort = true,
|
||||||
|
float = {
|
||||||
|
style = 'minimal',
|
||||||
|
border = 'rounded',
|
||||||
|
source = 'if_many',
|
||||||
|
header = '',
|
||||||
|
prefix = '',
|
||||||
|
},
|
||||||
|
signs = {
|
||||||
|
text = {
|
||||||
|
[vim.diagnostic.severity.ERROR] = '✘',
|
||||||
|
[vim.diagnostic.severity.WARN] = '▲',
|
||||||
|
[vim.diagnostic.severity.HINT] = '⚑',
|
||||||
|
[vim.diagnostic.severity.INFO] = '»',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local orig = vim.lsp.util.open_floating_preview
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
|
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.border = opts.border or 'rounded'
|
||||||
|
opts.max_width = opts.max_width or 80
|
||||||
|
opts.max_height = opts.max_height or 24
|
||||||
|
opts.wrap = opts.wrap ~= false
|
||||||
|
return orig(contents, syntax, opts, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
group = vim.api.nvim_create_augroup('my.lsp', {}),
|
||||||
|
callback = function(args)
|
||||||
|
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
||||||
|
local buf = args.buf
|
||||||
|
local map = function(mode, lhs, rhs) vim.keymap.set(mode, lhs, rhs, { buffer = buf }) end
|
||||||
|
|
||||||
|
map('n', 'K', vim.lsp.buf.hover)
|
||||||
|
map('n', 'gd', vim.lsp.buf.definition)
|
||||||
|
map('n', 'gD', vim.lsp.buf.declaration)
|
||||||
|
map('n', 'gi', vim.lsp.buf.implementation)
|
||||||
|
map('n', 'go', vim.lsp.buf.type_definition)
|
||||||
|
map('n', 'gr', vim.lsp.buf.references)
|
||||||
|
map('n', 'gs', vim.lsp.buf.signature_help)
|
||||||
|
map('n', 'gl', vim.diagnostic.open_float)
|
||||||
|
map('n', '<F2>', vim.lsp.buf.rename)
|
||||||
|
map({ 'n', 'x' }, '<F3>', function() vim.lsp.buf.format({ async = true }) end)
|
||||||
|
map('n', '<F4>', vim.lsp.buf.code_action)
|
||||||
|
|
||||||
|
if client:supports_method('textDocument/documentHighlight') then
|
||||||
|
local highlight_augroup = vim.api.nvim_create_augroup('my.lsp.highlight', { clear = false })
|
||||||
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
||||||
|
buffer = buf,
|
||||||
|
group = highlight_augroup,
|
||||||
|
callback = vim.lsp.buf.document_highlight,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
||||||
|
buffer = buf,
|
||||||
|
group = highlight_augroup,
|
||||||
|
callback = vim.lsp.buf.clear_references,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local excluded_filetypes = { php = true, c = true, cpp = true }
|
||||||
|
if not client:supports_method('textDocument/willSaveWaitUntil')
|
||||||
|
and client:supports_method('textDocument/formatting')
|
||||||
|
and not excluded_filetypes[vim.bo[buf].filetype]
|
||||||
|
then
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
group = vim.api.nvim_create_augroup('my.lsp.format', { clear = false }),
|
||||||
|
buffer = buf,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format({ bufnr = buf, id = client.id, timeout_ms = 1000 })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
local caps = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
vim.lsp.config['luals'] = {
|
||||||
|
cmd = { 'lua-language-server' },
|
||||||
|
filetypes = { 'lua' },
|
||||||
|
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = { version = 'LuaJIT' },
|
||||||
|
diagnostics = { globals = { 'vim' } },
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
library = vim.list_extend(
|
||||||
|
vim.api.nvim_get_runtime_file('', true),
|
||||||
|
{ '/home/tony/repos/oxwm/templates' }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['cssls'] = {
|
||||||
|
cmd = { 'vscode-css-language-server', '--stdio' },
|
||||||
|
filetypes = { 'css', 'scss', 'less' },
|
||||||
|
root_markers = { 'package.json', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
css = { validate = true },
|
||||||
|
scss = { validate = true },
|
||||||
|
less = { validate = true },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['phpls'] = {
|
||||||
|
cmd = { 'intelephense', '--stdio' },
|
||||||
|
filetypes = { 'php' },
|
||||||
|
root_markers = { 'composer.json', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
intelephense = {
|
||||||
|
files = {
|
||||||
|
maxSize = 5000000, -- default 5MB
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['ts_ls'] = {
|
||||||
|
cmd = { 'typescript-language-server', '--stdio' },
|
||||||
|
filetypes = {
|
||||||
|
'javascript', 'javascriptreact', 'javascript.jsx',
|
||||||
|
'typescript', 'typescriptreact', 'typescript.tsx',
|
||||||
|
},
|
||||||
|
root_markers = { 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
completions = {
|
||||||
|
completeFunctionCalls = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['zls'] = {
|
||||||
|
cmd = { 'zls' },
|
||||||
|
filetypes = { 'zig', 'zir' },
|
||||||
|
root_markers = { 'zls.json', 'build.zig', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
zls = {
|
||||||
|
enable_build_on_save = true,
|
||||||
|
build_on_save_step = "install",
|
||||||
|
warn_style = false,
|
||||||
|
enable_snippets = true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['nil_ls'] = {
|
||||||
|
cmd = { 'nil' },
|
||||||
|
filetypes = { 'nix' },
|
||||||
|
root_markers = { 'flake.nix', 'default.nix', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
['nil'] = {
|
||||||
|
formatting = {
|
||||||
|
command = { "alejandra" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['rust_analyzer'] = {
|
||||||
|
cmd = { 'rust-analyzer' },
|
||||||
|
filetypes = { 'rust' },
|
||||||
|
root_markers = { 'Cargo.toml', 'rust-project.json', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
['rust-analyzer'] = {
|
||||||
|
cargo = { allFeatures = true },
|
||||||
|
formatting = {
|
||||||
|
command = { "rustfmt" }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- C / C++ via clangd
|
||||||
|
vim.lsp.config['clangd'] = {
|
||||||
|
cmd = {
|
||||||
|
'clangd',
|
||||||
|
-- '--background-index',
|
||||||
|
-- '--clang-tidy',
|
||||||
|
-- '--header-insertion=never',
|
||||||
|
-- '--completion-style=detailed',
|
||||||
|
-- '--query-driver=/nix/store/*-gcc-*/bin/gcc*,/nix/store/*-clang-*/bin/clang*,/run/current-system/sw/bin/cc*',
|
||||||
|
},
|
||||||
|
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
||||||
|
root_markers = { 'compile_commands.json', '.clangd', 'configure.ac', 'Makefile', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
-- init_options = {
|
||||||
|
-- fallbackFlags = { '-std=c23' }, -- Default to C23
|
||||||
|
-- },
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['c3lsp'] = {
|
||||||
|
cmd = { 'c3-lsp' },
|
||||||
|
filetypes = { 'c3' },
|
||||||
|
root_markers = { 'project.json', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['serve_d'] = {
|
||||||
|
cmd = { 'serve-d' },
|
||||||
|
filetypes = { 'd' },
|
||||||
|
root_markers = { 'dub.sdl', 'dub.json', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['jsonls'] = {
|
||||||
|
cmd = { 'vscode-json-languageserver', '--stdio' },
|
||||||
|
filetypes = { 'json', 'jsonc' },
|
||||||
|
root_markers = { 'package.json', '.git', 'config.jsonc' },
|
||||||
|
capabilities = caps,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['hls'] = {
|
||||||
|
cmd = { 'haskell-language-server-wrapper', '--lsp' },
|
||||||
|
filetypes = { 'haskell', 'lhaskell' },
|
||||||
|
root_markers = { 'stack.yaml', 'cabal.project', 'package.yaml', '*.cabal', 'hie.yaml', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
haskell = {
|
||||||
|
formattingProvider = 'fourmolu',
|
||||||
|
plugin = {
|
||||||
|
semanticTokens = { globalOn = false }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['gopls'] = {
|
||||||
|
cmd = { 'gopls' },
|
||||||
|
filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
|
||||||
|
root_markers = { 'go.mod', 'go.work', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
analyses = {
|
||||||
|
unusedparams = false,
|
||||||
|
ST1003 = false,
|
||||||
|
ST1000 = false,
|
||||||
|
},
|
||||||
|
staticcheck = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['templ'] = {
|
||||||
|
cmd = { 'templ', 'lsp' },
|
||||||
|
filetypes = { 'templ' },
|
||||||
|
root_markers = { 'go.mod', '.git' },
|
||||||
|
capabilities = caps,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.filetype.add({
|
||||||
|
extension = {
|
||||||
|
h = 'c',
|
||||||
|
c3 = 'c3',
|
||||||
|
d = 'd',
|
||||||
|
templ = 'templ',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: invisible
|
||||||
|
for name, _ in pairs(vim.lsp.config._configs) do
|
||||||
|
if name ~= '*' then
|
||||||
|
vim.lsp.enable(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
40
config/nvim/plugin/quickformat.lua
Normal file
40
config/nvim/plugin/quickformat.lua
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
local function reformat_parenthesized_content()
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
|
local line = vim.api.nvim_buf_get_lines(bufnr, row - 1, row, false)[1]
|
||||||
|
|
||||||
|
local inside = line:match("%((.-)%)")
|
||||||
|
if not inside then
|
||||||
|
vim.notify(
|
||||||
|
"No content found inside parentheses",
|
||||||
|
vim.log.levels.ERROR
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local prefix = line:match("^(.-)%(") or ""
|
||||||
|
local suffix = line:match("%)(.*)$") or ""
|
||||||
|
|
||||||
|
local parts = vim.split(inside, ",%s*")
|
||||||
|
if #parts == 0 then
|
||||||
|
vim.notify("No comma-separated content found", vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local new_lines = {}
|
||||||
|
table.insert(new_lines, prefix .. "(")
|
||||||
|
for i, part in ipairs(parts) do
|
||||||
|
if i < #parts then
|
||||||
|
table.insert(new_lines, " " .. part .. ",")
|
||||||
|
else
|
||||||
|
table.insert(new_lines, " " .. part)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(new_lines, " )" .. suffix)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, row - 1, row, false, new_lines)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>qq", function()
|
||||||
|
reformat_parenthesized_content()
|
||||||
|
end)
|
||||||
110
config/nvim/plugin/tonycontext.lua
Normal file
110
config/nvim/plugin/tonycontext.lua
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
-- Minimal sticky context header. Replaces nvim-treesitter-context.
|
||||||
|
-- Shows the first line of the enclosing function/class pinned to the
|
||||||
|
-- top of the window when that line has scrolled offscreen above.
|
||||||
|
--
|
||||||
|
-- One level of context only (innermost enclosing). Extend CONTEXT_TYPES
|
||||||
|
-- to support more languages or richer node kinds.
|
||||||
|
--
|
||||||
|
-- Toggle:
|
||||||
|
-- <leader>th hide
|
||||||
|
-- <leader>tu unhide
|
||||||
|
|
||||||
|
local M = { enabled = true }
|
||||||
|
local ctx_buf, ctx_win
|
||||||
|
|
||||||
|
local CONTEXT_TYPES = {
|
||||||
|
-- C / PHP
|
||||||
|
function_definition = true,
|
||||||
|
method_declaration = true,
|
||||||
|
class_declaration = true,
|
||||||
|
-- Lua
|
||||||
|
function_declaration = true,
|
||||||
|
-- Rust
|
||||||
|
function_item = true,
|
||||||
|
impl_item = true,
|
||||||
|
trait_item = true,
|
||||||
|
-- Go (function_declaration shared)
|
||||||
|
-- JS
|
||||||
|
method_definition = true,
|
||||||
|
arrow_function = true,
|
||||||
|
-- Zig
|
||||||
|
fn_proto = true,
|
||||||
|
-- Nix
|
||||||
|
function_expression = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function close_ctx()
|
||||||
|
if ctx_win and vim.api.nvim_win_is_valid(ctx_win) then
|
||||||
|
vim.api.nvim_win_close(ctx_win, true)
|
||||||
|
end
|
||||||
|
ctx_win = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function update_ctx()
|
||||||
|
if not M.enabled then close_ctx() return end
|
||||||
|
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
local node = vim.treesitter.get_node()
|
||||||
|
if not node then close_ctx() return end
|
||||||
|
|
||||||
|
while node and not CONTEXT_TYPES[node:type()] do
|
||||||
|
node = node:parent()
|
||||||
|
end
|
||||||
|
if not node then close_ctx() return end
|
||||||
|
|
||||||
|
local sr = node:start()
|
||||||
|
local top_visible = vim.fn.line("w0") - 1
|
||||||
|
if sr >= top_visible then close_ctx() return end
|
||||||
|
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(bufnr, sr, sr + 1, false)
|
||||||
|
if #lines == 0 then close_ctx() return end
|
||||||
|
|
||||||
|
if not ctx_buf or not vim.api.nvim_buf_is_valid(ctx_buf) then
|
||||||
|
ctx_buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
vim.bo[ctx_buf].buftype = "nofile"
|
||||||
|
end
|
||||||
|
vim.api.nvim_buf_set_lines(ctx_buf, 0, -1, false, lines)
|
||||||
|
vim.bo[ctx_buf].filetype = vim.bo[bufnr].filetype
|
||||||
|
|
||||||
|
local config = {
|
||||||
|
relative = "win",
|
||||||
|
win = vim.api.nvim_get_current_win(),
|
||||||
|
row = 0,
|
||||||
|
col = 0,
|
||||||
|
width = vim.api.nvim_win_get_width(0),
|
||||||
|
height = 1,
|
||||||
|
focusable = false,
|
||||||
|
style = "minimal",
|
||||||
|
zindex = 20,
|
||||||
|
}
|
||||||
|
if ctx_win and vim.api.nvim_win_is_valid(ctx_win) then
|
||||||
|
vim.api.nvim_win_set_config(ctx_win, config)
|
||||||
|
else
|
||||||
|
ctx_win = vim.api.nvim_open_win(ctx_buf, false, config)
|
||||||
|
vim.wo[ctx_win].winhighlight = "Normal:TonyContext,NormalFloat:TonyContext"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "TonyContext", { link = "NormalFloat", default = true })
|
||||||
|
|
||||||
|
local group = vim.api.nvim_create_augroup("TonyContext", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI", "WinScrolled", "BufEnter" }, {
|
||||||
|
group = group,
|
||||||
|
callback = update_ctx,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd({ "BufLeave", "WinLeave" }, {
|
||||||
|
group = group,
|
||||||
|
callback = close_ctx,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>th", function()
|
||||||
|
M.enabled = false
|
||||||
|
close_ctx()
|
||||||
|
end, { desc = "Hide context header" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>tu", function()
|
||||||
|
M.enabled = true
|
||||||
|
update_ctx()
|
||||||
|
end, { desc = "Unhide context header" })
|
||||||
|
|
||||||
|
return M
|
||||||
86
config/nvim/plugin/tonysitter.lua
Normal file
86
config/nvim/plugin/tonysitter.lua
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
local function case_directive(transform)
|
||||||
|
return function(match, _, bufnr, pred, metadata)
|
||||||
|
local id = pred[2]
|
||||||
|
if type(id) ~= "number" then return end
|
||||||
|
local nodes = match[id]
|
||||||
|
if not nodes or #nodes == 0 then return end
|
||||||
|
local node = nodes[1]
|
||||||
|
local text = vim.treesitter.get_node_text(node, bufnr, { metadata = metadata[id] }) or ""
|
||||||
|
if not metadata[id] then metadata[id] = {} end
|
||||||
|
metadata[id].text = transform(text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.treesitter.query.add_directive("downcase!", case_directive(string.lower), { force = true })
|
||||||
|
vim.treesitter.query.add_directive("upcase!", case_directive(string.upper), { force = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
callback = function(args)
|
||||||
|
pcall(vim.treesitter.start, args.buf)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- smallest @function.outer / @function.inner range containing the cursor.
|
||||||
|
local function select_function(capture)
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
|
||||||
|
if not ok or not parser then return end
|
||||||
|
|
||||||
|
local lang = parser:lang()
|
||||||
|
local query = vim.treesitter.query.get(lang, "textobjects")
|
||||||
|
if not query then return end
|
||||||
|
|
||||||
|
local tree = parser:parse()[1]
|
||||||
|
if not tree then return end
|
||||||
|
local root = tree:root()
|
||||||
|
|
||||||
|
local cur = vim.api.nvim_win_get_cursor(0)
|
||||||
|
local crow, ccol = cur[1] - 1, cur[2]
|
||||||
|
|
||||||
|
local best, best_size
|
||||||
|
for _, match in query:iter_matches(root, bufnr, 0, -1, { all = true }) do
|
||||||
|
local min_sr, min_sc, max_er, max_ec
|
||||||
|
for id, nodes in pairs(match) do
|
||||||
|
if query.captures[id] == capture then
|
||||||
|
if type(nodes) ~= "table" then nodes = { nodes } end
|
||||||
|
for _, node in ipairs(nodes) do
|
||||||
|
local sr, sc, er, ec = node:range()
|
||||||
|
if not min_sr or sr < min_sr or (sr == min_sr and sc < min_sc) then
|
||||||
|
min_sr, min_sc = sr, sc
|
||||||
|
end
|
||||||
|
if not max_er or er > max_er or (er == max_er and ec > max_ec) then
|
||||||
|
max_er, max_ec = er, ec
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if min_sr then
|
||||||
|
local contains = (min_sr < crow or (min_sr == crow and min_sc <= ccol))
|
||||||
|
and (max_er > crow or (max_er == crow and max_ec >= ccol))
|
||||||
|
if contains then
|
||||||
|
local size = (max_er - min_sr) * 1e6 + (max_ec - min_sc)
|
||||||
|
if not best_size or size < best_size then
|
||||||
|
best_size = size
|
||||||
|
best = { min_sr, min_sc, max_er, max_ec }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not best then return end
|
||||||
|
local sr, sc, er, ec = best[1], best[2], best[3], best[4]
|
||||||
|
|
||||||
|
local mode = vim.fn.mode()
|
||||||
|
if mode == "v" or mode == "V" or mode == "\22" then
|
||||||
|
vim.api.nvim_feedkeys(
|
||||||
|
vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "nx", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_win_set_cursor(0, { sr + 1, sc })
|
||||||
|
vim.cmd("normal! v")
|
||||||
|
vim.api.nvim_win_set_cursor(0, { er + 1, math.max(0, ec - 1) })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set({ "x", "o" }, "af", function() select_function("function.outer") end,
|
||||||
|
{ desc = "around function" })
|
||||||
|
vim.keymap.set({ "x", "o" }, "if", function() select_function("function.inner") end,
|
||||||
|
{ desc = "inside function" })
|
||||||
23
config/nvim/queries/c/folds.scm
Normal file
23
config/nvim/queries/c/folds.scm
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[
|
||||||
|
(for_statement)
|
||||||
|
(if_statement)
|
||||||
|
(while_statement)
|
||||||
|
(do_statement)
|
||||||
|
(switch_statement)
|
||||||
|
(case_statement)
|
||||||
|
(function_definition)
|
||||||
|
(struct_specifier)
|
||||||
|
(enum_specifier)
|
||||||
|
(comment)
|
||||||
|
(preproc_if)
|
||||||
|
(preproc_elif)
|
||||||
|
(preproc_else)
|
||||||
|
(preproc_ifdef)
|
||||||
|
(preproc_function_def)
|
||||||
|
(initializer_list)
|
||||||
|
(gnu_asm_expression)
|
||||||
|
(preproc_include)+
|
||||||
|
] @fold
|
||||||
|
|
||||||
|
(compound_statement
|
||||||
|
(compound_statement) @fold)
|
||||||
341
config/nvim/queries/c/highlights.scm
Normal file
341
config/nvim/queries/c/highlights.scm
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
|
||||||
|
((identifier) @variable
|
||||||
|
(#set! priority 95))
|
||||||
|
|
||||||
|
(preproc_def
|
||||||
|
(preproc_arg) @variable)
|
||||||
|
|
||||||
|
[
|
||||||
|
"default"
|
||||||
|
"goto"
|
||||||
|
"asm"
|
||||||
|
"__asm__"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"enum"
|
||||||
|
"struct"
|
||||||
|
"union"
|
||||||
|
"typedef"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
[
|
||||||
|
"sizeof"
|
||||||
|
"offsetof"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
(alignof_expression
|
||||||
|
.
|
||||||
|
_ @keyword.operator)
|
||||||
|
|
||||||
|
"return" @keyword.return
|
||||||
|
|
||||||
|
[
|
||||||
|
"while"
|
||||||
|
"for"
|
||||||
|
"do"
|
||||||
|
"continue"
|
||||||
|
"break"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"else"
|
||||||
|
"case"
|
||||||
|
"switch"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"#if"
|
||||||
|
"#ifdef"
|
||||||
|
"#ifndef"
|
||||||
|
"#else"
|
||||||
|
"#elif"
|
||||||
|
"#endif"
|
||||||
|
"#elifdef"
|
||||||
|
"#elifndef"
|
||||||
|
(preproc_directive)
|
||||||
|
] @keyword.directive
|
||||||
|
|
||||||
|
"#define" @keyword.directive.define
|
||||||
|
|
||||||
|
"#include" @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
";"
|
||||||
|
":"
|
||||||
|
","
|
||||||
|
"."
|
||||||
|
"::"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
"..." @punctuation.special
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
"="
|
||||||
|
"-"
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"+"
|
||||||
|
"%"
|
||||||
|
"~"
|
||||||
|
"|"
|
||||||
|
"&"
|
||||||
|
"^"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"->"
|
||||||
|
"<"
|
||||||
|
"<="
|
||||||
|
">="
|
||||||
|
">"
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
"!"
|
||||||
|
"&&"
|
||||||
|
"||"
|
||||||
|
"-="
|
||||||
|
"+="
|
||||||
|
"*="
|
||||||
|
"/="
|
||||||
|
"%="
|
||||||
|
"|="
|
||||||
|
"&="
|
||||||
|
"^="
|
||||||
|
">>="
|
||||||
|
"<<="
|
||||||
|
"--"
|
||||||
|
"++"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Make sure the comma operator is given a highlight group after the comma
|
||||||
|
; punctuator so the operator is highlighted properly.
|
||||||
|
(comma_expression
|
||||||
|
"," @operator)
|
||||||
|
|
||||||
|
[
|
||||||
|
(true)
|
||||||
|
(false)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
(conditional_expression
|
||||||
|
[
|
||||||
|
"?"
|
||||||
|
":"
|
||||||
|
] @keyword.conditional.ternary)
|
||||||
|
|
||||||
|
(string_literal) @string
|
||||||
|
|
||||||
|
(system_lib_string) @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
(null) @constant.builtin
|
||||||
|
|
||||||
|
(number_literal) @number
|
||||||
|
|
||||||
|
(char_literal) @character
|
||||||
|
|
||||||
|
(preproc_defined) @function.macro
|
||||||
|
|
||||||
|
((field_expression
|
||||||
|
(field_identifier) @property) @_parent
|
||||||
|
(#not-has-parent? @_parent template_method function_declarator call_expression))
|
||||||
|
|
||||||
|
(field_designator) @property
|
||||||
|
|
||||||
|
((field_identifier) @property
|
||||||
|
(#has-ancestor? @property field_declaration)
|
||||||
|
(#not-has-ancestor? @property function_declarator))
|
||||||
|
|
||||||
|
(statement_identifier) @label
|
||||||
|
|
||||||
|
(declaration
|
||||||
|
type: (type_identifier) @_type
|
||||||
|
declarator: (identifier) @label
|
||||||
|
(#eq? @_type "__label__"))
|
||||||
|
|
||||||
|
[
|
||||||
|
(type_identifier)
|
||||||
|
(type_descriptor)
|
||||||
|
] @type
|
||||||
|
|
||||||
|
(storage_class_specifier) @keyword.modifier
|
||||||
|
|
||||||
|
[
|
||||||
|
(type_qualifier)
|
||||||
|
(gnu_asm_qualifier)
|
||||||
|
"__extension__"
|
||||||
|
] @keyword.modifier
|
||||||
|
|
||||||
|
(linkage_specification
|
||||||
|
"extern" @keyword.modifier)
|
||||||
|
|
||||||
|
(type_definition
|
||||||
|
declarator: (type_identifier) @type.definition)
|
||||||
|
|
||||||
|
(primitive_type) @type.builtin
|
||||||
|
|
||||||
|
(sized_type_specifier
|
||||||
|
_ @type.builtin
|
||||||
|
type: _?)
|
||||||
|
|
||||||
|
((identifier) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||||
|
|
||||||
|
(preproc_def
|
||||||
|
(preproc_arg) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||||
|
|
||||||
|
(enumerator
|
||||||
|
name: (identifier) @constant)
|
||||||
|
|
||||||
|
(case_statement
|
||||||
|
value: (identifier) @constant)
|
||||||
|
|
||||||
|
((identifier) @constant.builtin
|
||||||
|
; format-ignore
|
||||||
|
(#any-of? @constant.builtin
|
||||||
|
"stderr" "stdin" "stdout"
|
||||||
|
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
|
||||||
|
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
|
||||||
|
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
|
||||||
|
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
|
||||||
|
"__TIMESTAMP__" "__clang__" "__clang_major__"
|
||||||
|
"__clang_minor__" "__clang_patchlevel__"
|
||||||
|
"__clang_version__" "__clang_literal_encoding__"
|
||||||
|
"__clang_wide_literal_encoding__"
|
||||||
|
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
|
||||||
|
"__VA_ARGS__" "__VA_OPT__"))
|
||||||
|
|
||||||
|
(preproc_def
|
||||||
|
(preproc_arg) @constant.builtin
|
||||||
|
; format-ignore
|
||||||
|
(#any-of? @constant.builtin
|
||||||
|
"stderr" "stdin" "stdout"
|
||||||
|
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
|
||||||
|
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
|
||||||
|
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
|
||||||
|
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
|
||||||
|
"__TIMESTAMP__" "__clang__" "__clang_major__"
|
||||||
|
"__clang_minor__" "__clang_patchlevel__"
|
||||||
|
"__clang_version__" "__clang_literal_encoding__"
|
||||||
|
"__clang_wide_literal_encoding__"
|
||||||
|
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
|
||||||
|
"__VA_ARGS__" "__VA_OPT__"))
|
||||||
|
|
||||||
|
(attribute_specifier
|
||||||
|
(argument_list
|
||||||
|
(identifier) @variable.builtin))
|
||||||
|
|
||||||
|
(attribute_specifier
|
||||||
|
(argument_list
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @variable.builtin)))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @function.builtin)
|
||||||
|
(#lua-match? @function.builtin "^__builtin_"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @function.builtin)
|
||||||
|
(#has-ancestor? @function.builtin attribute_specifier))
|
||||||
|
|
||||||
|
; Preproc def / undef
|
||||||
|
(preproc_def
|
||||||
|
name: (_) @constant.macro)
|
||||||
|
|
||||||
|
(preproc_call
|
||||||
|
directive: (preproc_directive) @_u
|
||||||
|
argument: (_) @constant.macro
|
||||||
|
(#eq? @_u "#undef"))
|
||||||
|
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier) @constant.macro)
|
||||||
|
|
||||||
|
(preproc_elifdef
|
||||||
|
name: (identifier) @constant.macro)
|
||||||
|
|
||||||
|
(preproc_defined
|
||||||
|
(identifier) @constant.macro)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (field_expression
|
||||||
|
field: (field_identifier) @function.call))
|
||||||
|
|
||||||
|
(function_declarator
|
||||||
|
declarator: (identifier) @function)
|
||||||
|
|
||||||
|
(function_declarator
|
||||||
|
declarator: (parenthesized_declarator
|
||||||
|
(pointer_declarator
|
||||||
|
declarator: (field_identifier) @function)))
|
||||||
|
|
||||||
|
(preproc_function_def
|
||||||
|
name: (identifier) @function.macro)
|
||||||
|
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
((comment) @comment.documentation
|
||||||
|
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
(parameter_declaration
|
||||||
|
declarator: (identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
declarator: (array_declarator) @variable.parameter)
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
declarator: (pointer_declarator) @variable.parameter)
|
||||||
|
|
||||||
|
; K&R functions
|
||||||
|
; To enable support for K&R functions,
|
||||||
|
; add the following lines to your own query config and uncomment them.
|
||||||
|
; They are commented out as they'll conflict with C++
|
||||||
|
; Note that you'll need to have `; extends` at the top of your query file.
|
||||||
|
;
|
||||||
|
; (parameter_list (identifier) @variable.parameter)
|
||||||
|
;
|
||||||
|
; (function_definition
|
||||||
|
; declarator: _
|
||||||
|
; (declaration
|
||||||
|
; declarator: (identifier) @variable.parameter))
|
||||||
|
;
|
||||||
|
; (function_definition
|
||||||
|
; declarator: _
|
||||||
|
; (declaration
|
||||||
|
; declarator: (array_declarator) @variable.parameter))
|
||||||
|
;
|
||||||
|
; (function_definition
|
||||||
|
; declarator: _
|
||||||
|
; (declaration
|
||||||
|
; declarator: (pointer_declarator) @variable.parameter))
|
||||||
|
(preproc_params
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
[
|
||||||
|
"__attribute__"
|
||||||
|
"__declspec"
|
||||||
|
"__based"
|
||||||
|
"__cdecl"
|
||||||
|
"__clrcall"
|
||||||
|
"__stdcall"
|
||||||
|
"__fastcall"
|
||||||
|
"__thiscall"
|
||||||
|
"__vectorcall"
|
||||||
|
(ms_pointer_modifier)
|
||||||
|
(attribute_declaration)
|
||||||
|
] @attribute
|
||||||
128
config/nvim/queries/c/injections.scm
Normal file
128
config/nvim/queries/c/injections.scm
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
((preproc_arg) @injection.content
|
||||||
|
(#set! injection.language "c"))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||||
|
(#set! injection.language "re2c"))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]")
|
||||||
|
(#set! injection.language "doxygen"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @_function
|
||||||
|
arguments: (argument_list
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content)
|
||||||
|
(concatenated_string
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content))
|
||||||
|
]))
|
||||||
|
; format-ignore
|
||||||
|
(#any-of? @_function
|
||||||
|
"printf" "printf_s"
|
||||||
|
"vprintf" "vprintf_s"
|
||||||
|
"scanf" "scanf_s"
|
||||||
|
"vscanf" "vscanf_s"
|
||||||
|
"wprintf" "wprintf_s"
|
||||||
|
"vwprintf" "vwprintf_s"
|
||||||
|
"wscanf" "wscanf_s"
|
||||||
|
"vwscanf" "vwscanf_s"
|
||||||
|
"cscanf" "_cscanf"
|
||||||
|
"printw"
|
||||||
|
"scanw")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @_function
|
||||||
|
arguments: (argument_list
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content)
|
||||||
|
(concatenated_string
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content))
|
||||||
|
]))
|
||||||
|
; format-ignore
|
||||||
|
(#any-of? @_function
|
||||||
|
"fprintf" "fprintf_s"
|
||||||
|
"sprintf"
|
||||||
|
"dprintf"
|
||||||
|
"fscanf" "fscanf_s"
|
||||||
|
"sscanf" "sscanf_s"
|
||||||
|
"vsscanf" "vsscanf_s"
|
||||||
|
"vfprintf" "vfprintf_s"
|
||||||
|
"vsprintf"
|
||||||
|
"vdprintf"
|
||||||
|
"fwprintf" "fwprintf_s"
|
||||||
|
"vfwprintf" "vfwprintf_s"
|
||||||
|
"fwscanf" "fwscanf_s"
|
||||||
|
"swscanf" "swscanf_s"
|
||||||
|
"vswscanf" "vswscanf_s"
|
||||||
|
"vfscanf" "vfscanf_s"
|
||||||
|
"vfwscanf" "vfwscanf_s"
|
||||||
|
"wprintw"
|
||||||
|
"vw_printw" "vwprintw"
|
||||||
|
"wscanw"
|
||||||
|
"vw_scanw" "vwscanw")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @_function
|
||||||
|
arguments: (argument_list
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content)
|
||||||
|
(concatenated_string
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content))
|
||||||
|
]))
|
||||||
|
; format-ignore
|
||||||
|
(#any-of? @_function
|
||||||
|
"sprintf_s"
|
||||||
|
"snprintf" "snprintf_s"
|
||||||
|
"vsprintf_s"
|
||||||
|
"vsnprintf" "vsnprintf_s"
|
||||||
|
"swprintf" "swprintf_s"
|
||||||
|
"snwprintf_s"
|
||||||
|
"vswprintf" "vswprintf_s"
|
||||||
|
"vsnwprintf_s"
|
||||||
|
"mvprintw"
|
||||||
|
"mvscanw")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @_function
|
||||||
|
arguments: (argument_list
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content)
|
||||||
|
(concatenated_string
|
||||||
|
(string_literal
|
||||||
|
(string_content) @injection.content))
|
||||||
|
]))
|
||||||
|
(#any-of? @_function "mvwprintw" "mvwscanw")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
; TODO: add when asm is added
|
||||||
|
; (gnu_asm_expression assembly_code: (string_literal) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content)
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
67
config/nvim/queries/c/locals.scm
Normal file
67
config/nvim/queries/c/locals.scm
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
; Functions definitions
|
||||||
|
(function_declarator
|
||||||
|
declarator: (identifier) @local.definition.function)
|
||||||
|
|
||||||
|
(preproc_function_def
|
||||||
|
name: (identifier) @local.definition.macro) @local.scope
|
||||||
|
|
||||||
|
(preproc_def
|
||||||
|
name: (identifier) @local.definition.macro)
|
||||||
|
|
||||||
|
(pointer_declarator
|
||||||
|
declarator: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
declarator: (identifier) @local.definition.parameter)
|
||||||
|
|
||||||
|
(init_declarator
|
||||||
|
declarator: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(array_declarator
|
||||||
|
declarator: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(declaration
|
||||||
|
declarator: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(enum_specifier
|
||||||
|
name: (_) @local.definition.type
|
||||||
|
(enumerator_list
|
||||||
|
(enumerator
|
||||||
|
name: (identifier) @local.definition.var)))
|
||||||
|
|
||||||
|
; Type / Struct / Enum
|
||||||
|
(field_declaration
|
||||||
|
declarator: (field_identifier) @local.definition.field)
|
||||||
|
|
||||||
|
(type_definition
|
||||||
|
declarator: (type_identifier) @local.definition.type)
|
||||||
|
|
||||||
|
(struct_specifier
|
||||||
|
name: (type_identifier) @local.definition.type)
|
||||||
|
|
||||||
|
; goto
|
||||||
|
(labeled_statement
|
||||||
|
(statement_identifier) @local.definition)
|
||||||
|
|
||||||
|
; References
|
||||||
|
(identifier) @local.reference
|
||||||
|
|
||||||
|
((field_identifier) @local.reference
|
||||||
|
(#set! reference.kind "field"))
|
||||||
|
|
||||||
|
((type_identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(goto_statement
|
||||||
|
(statement_identifier) @local.reference)
|
||||||
|
|
||||||
|
; Scope
|
||||||
|
[
|
||||||
|
(for_statement)
|
||||||
|
(if_statement)
|
||||||
|
(while_statement)
|
||||||
|
(translation_unit)
|
||||||
|
(function_definition)
|
||||||
|
(compound_statement) ; a block in curly braces
|
||||||
|
(struct_specifier)
|
||||||
|
] @local.scope
|
||||||
151
config/nvim/queries/c/textobjects.scm
Normal file
151
config/nvim/queries/c/textobjects.scm
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
(declaration
|
||||||
|
declarator: (function_declarator)) @function.outer
|
||||||
|
|
||||||
|
(function_definition
|
||||||
|
body: (compound_statement)) @function.outer
|
||||||
|
|
||||||
|
(function_definition
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(struct_specifier
|
||||||
|
body: (_) @class.inner) @class.outer
|
||||||
|
|
||||||
|
(enum_specifier
|
||||||
|
body: (_) @class.inner) @class.outer
|
||||||
|
|
||||||
|
; conditionals
|
||||||
|
(if_statement
|
||||||
|
consequence: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}")) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
alternative: (else_clause
|
||||||
|
(compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}"))) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
condition: (_) @conditional.inner
|
||||||
|
(#offset! @conditional.inner 0 1 0 -1))
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
condition: (_) @conditional.inner
|
||||||
|
(#offset! @conditional.inner 0 1 0 -1))
|
||||||
|
|
||||||
|
(do_statement
|
||||||
|
condition: (_) @conditional.inner
|
||||||
|
(#offset! @conditional.inner 0 1 0 -1))
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
; loops
|
||||||
|
(while_statement) @loop.outer
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(for_statement) @loop.outer
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(do_statement) @loop.outer
|
||||||
|
|
||||||
|
(do_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(compound_statement) @block.outer
|
||||||
|
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
(call_expression) @call.outer
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
arguments: (argument_list
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(return_statement
|
||||||
|
(_)? @return.inner) @return.outer
|
||||||
|
|
||||||
|
; Statements
|
||||||
|
;(expression_statement ;; this is what we actually want to capture in most cases (";" is missing) probably
|
||||||
|
;(_) @statement.inner) ;; the other statement like node type is declaration but declaration has a ";"
|
||||||
|
(compound_statement
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(field_declaration_list
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(preproc_if
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(preproc_elif
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(preproc_else
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(parameter_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(parameter_declaration) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(parameter_list
|
||||||
|
.
|
||||||
|
(parameter_declaration) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(argument_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(argument_list
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(number_literal) @number.inner
|
||||||
|
|
||||||
|
(declaration
|
||||||
|
declarator: (init_declarator
|
||||||
|
declarator: (_) @assignment.lhs
|
||||||
|
value: (_) @assignment.rhs) @assignment.inner) @assignment.outer
|
||||||
|
|
||||||
|
(declaration
|
||||||
|
type: (primitive_type)
|
||||||
|
declarator: (_) @assignment.inner)
|
||||||
|
|
||||||
|
(expression_statement
|
||||||
|
(assignment_expression
|
||||||
|
left: (_) @assignment.lhs
|
||||||
|
right: (_) @assignment.rhs) @assignment.inner) @assignment.outer
|
||||||
24
config/nvim/queries/ecma/folds.scm
Normal file
24
config/nvim/queries/ecma/folds.scm
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[
|
||||||
|
(arguments)
|
||||||
|
(for_in_statement)
|
||||||
|
(for_statement)
|
||||||
|
(while_statement)
|
||||||
|
(arrow_function)
|
||||||
|
(function_expression)
|
||||||
|
(function_declaration)
|
||||||
|
(class_declaration)
|
||||||
|
(method_definition)
|
||||||
|
(do_statement)
|
||||||
|
(with_statement)
|
||||||
|
(switch_statement)
|
||||||
|
(switch_case)
|
||||||
|
(switch_default)
|
||||||
|
(import_statement)+
|
||||||
|
(if_statement)
|
||||||
|
(try_statement)
|
||||||
|
(catch_clause)
|
||||||
|
(array)
|
||||||
|
(object)
|
||||||
|
(generator_function)
|
||||||
|
(generator_function_declaration)
|
||||||
|
] @fold
|
||||||
392
config/nvim/queries/ecma/highlights.scm
Normal file
392
config/nvim/queries/ecma/highlights.scm
Normal file
@@ -0,0 +1,392 @@
|
|||||||
|
; Types
|
||||||
|
; Javascript
|
||||||
|
; Variables
|
||||||
|
;-----------
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
; Properties
|
||||||
|
;-----------
|
||||||
|
(property_identifier) @variable.member
|
||||||
|
|
||||||
|
(shorthand_property_identifier) @variable.member
|
||||||
|
|
||||||
|
(private_property_identifier) @variable.member
|
||||||
|
|
||||||
|
(object_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @variable)
|
||||||
|
|
||||||
|
(object_pattern
|
||||||
|
(object_assignment_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @variable))
|
||||||
|
|
||||||
|
; Special identifiers
|
||||||
|
;--------------------
|
||||||
|
((identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
((identifier) @constant
|
||||||
|
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
|
||||||
|
|
||||||
|
((shorthand_property_identifier) @constant
|
||||||
|
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
|
||||||
|
|
||||||
|
((identifier) @variable.builtin
|
||||||
|
(#any-of? @variable.builtin "arguments" "module" "console" "window" "document"))
|
||||||
|
|
||||||
|
((identifier) @type.builtin
|
||||||
|
(#any-of? @type.builtin
|
||||||
|
"Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set"
|
||||||
|
"WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array"
|
||||||
|
"Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView"
|
||||||
|
"Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError"
|
||||||
|
"URIError"))
|
||||||
|
|
||||||
|
(statement_identifier) @label
|
||||||
|
|
||||||
|
; Function and method definitions
|
||||||
|
;--------------------------------
|
||||||
|
(function_expression
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
(generator_function
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
(generator_function_declaration
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
(method_definition
|
||||||
|
name: [
|
||||||
|
(property_identifier)
|
||||||
|
(private_property_identifier)
|
||||||
|
] @function.method)
|
||||||
|
|
||||||
|
(method_definition
|
||||||
|
name: (property_identifier) @constructor
|
||||||
|
(#eq? @constructor "constructor"))
|
||||||
|
|
||||||
|
(pair
|
||||||
|
key: (property_identifier) @function.method
|
||||||
|
value: (function_expression))
|
||||||
|
|
||||||
|
(pair
|
||||||
|
key: (property_identifier) @function.method
|
||||||
|
value: (arrow_function))
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
left: (member_expression
|
||||||
|
property: (property_identifier) @function.method)
|
||||||
|
right: (arrow_function))
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
left: (member_expression
|
||||||
|
property: (property_identifier) @function.method)
|
||||||
|
right: (function_expression))
|
||||||
|
|
||||||
|
(variable_declarator
|
||||||
|
name: (identifier) @function
|
||||||
|
value: (arrow_function))
|
||||||
|
|
||||||
|
(variable_declarator
|
||||||
|
name: (identifier) @function
|
||||||
|
value: (function_expression))
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
left: (identifier) @function
|
||||||
|
right: (arrow_function))
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
left: (identifier) @function
|
||||||
|
right: (function_expression))
|
||||||
|
|
||||||
|
; Function and method calls
|
||||||
|
;--------------------------
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (member_expression
|
||||||
|
property: [
|
||||||
|
(property_identifier)
|
||||||
|
(private_property_identifier)
|
||||||
|
] @function.method.call))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (await_expression
|
||||||
|
(identifier) @function.call))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (await_expression
|
||||||
|
(member_expression
|
||||||
|
property: [
|
||||||
|
(property_identifier)
|
||||||
|
(private_property_identifier)
|
||||||
|
] @function.method.call)))
|
||||||
|
|
||||||
|
; Builtins
|
||||||
|
;---------
|
||||||
|
((identifier) @module.builtin
|
||||||
|
(#eq? @module.builtin "Intl"))
|
||||||
|
|
||||||
|
((identifier) @function.builtin
|
||||||
|
(#any-of? @function.builtin
|
||||||
|
"eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI"
|
||||||
|
"encodeURIComponent" "require"))
|
||||||
|
|
||||||
|
; Constructor
|
||||||
|
;------------
|
||||||
|
(new_expression
|
||||||
|
constructor: (identifier) @constructor)
|
||||||
|
|
||||||
|
; Decorators
|
||||||
|
;----------
|
||||||
|
(decorator
|
||||||
|
"@" @attribute
|
||||||
|
(identifier) @attribute)
|
||||||
|
|
||||||
|
(decorator
|
||||||
|
"@" @attribute
|
||||||
|
(call_expression
|
||||||
|
(identifier) @attribute))
|
||||||
|
|
||||||
|
(decorator
|
||||||
|
"@" @attribute
|
||||||
|
(member_expression
|
||||||
|
(property_identifier) @attribute))
|
||||||
|
|
||||||
|
(decorator
|
||||||
|
"@" @attribute
|
||||||
|
(call_expression
|
||||||
|
(member_expression
|
||||||
|
(property_identifier) @attribute)))
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
;---------
|
||||||
|
[
|
||||||
|
(this)
|
||||||
|
(super)
|
||||||
|
] @variable.builtin
|
||||||
|
|
||||||
|
((identifier) @variable.builtin
|
||||||
|
(#eq? @variable.builtin "self"))
|
||||||
|
|
||||||
|
[
|
||||||
|
(true)
|
||||||
|
(false)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
[
|
||||||
|
(null)
|
||||||
|
(undefined)
|
||||||
|
] @constant.builtin
|
||||||
|
|
||||||
|
[
|
||||||
|
(comment)
|
||||||
|
(html_comment)
|
||||||
|
] @comment @spell
|
||||||
|
|
||||||
|
((comment) @comment.documentation
|
||||||
|
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||||
|
|
||||||
|
(hash_bang_line) @keyword.directive
|
||||||
|
|
||||||
|
((string_fragment) @keyword.directive
|
||||||
|
(#eq? @keyword.directive "use strict"))
|
||||||
|
|
||||||
|
(string) @string
|
||||||
|
|
||||||
|
(template_string) @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
(regex_pattern) @string.regexp
|
||||||
|
|
||||||
|
(regex_flags) @character.special
|
||||||
|
|
||||||
|
(regex
|
||||||
|
"/" @punctuation.bracket) ; Regex delimiters
|
||||||
|
|
||||||
|
(number) @number
|
||||||
|
|
||||||
|
((identifier) @number
|
||||||
|
(#any-of? @number "NaN" "Infinity"))
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
|
;------------
|
||||||
|
[
|
||||||
|
";"
|
||||||
|
"."
|
||||||
|
","
|
||||||
|
":"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
"--"
|
||||||
|
"-"
|
||||||
|
"-="
|
||||||
|
"&&"
|
||||||
|
"+"
|
||||||
|
"++"
|
||||||
|
"+="
|
||||||
|
"&="
|
||||||
|
"/="
|
||||||
|
"**="
|
||||||
|
"<<="
|
||||||
|
"<"
|
||||||
|
"<="
|
||||||
|
"<<"
|
||||||
|
"="
|
||||||
|
"=="
|
||||||
|
"==="
|
||||||
|
"!="
|
||||||
|
"!=="
|
||||||
|
"=>"
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
">>"
|
||||||
|
"||"
|
||||||
|
"%"
|
||||||
|
"%="
|
||||||
|
"*"
|
||||||
|
"**"
|
||||||
|
">>>"
|
||||||
|
"&"
|
||||||
|
"|"
|
||||||
|
"^"
|
||||||
|
"??"
|
||||||
|
"*="
|
||||||
|
">>="
|
||||||
|
">>>="
|
||||||
|
"^="
|
||||||
|
"|="
|
||||||
|
"&&="
|
||||||
|
"||="
|
||||||
|
"??="
|
||||||
|
"..."
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
(binary_expression
|
||||||
|
"/" @operator)
|
||||||
|
|
||||||
|
(ternary_expression
|
||||||
|
[
|
||||||
|
"?"
|
||||||
|
":"
|
||||||
|
] @keyword.conditional.ternary)
|
||||||
|
|
||||||
|
(unary_expression
|
||||||
|
[
|
||||||
|
"!"
|
||||||
|
"~"
|
||||||
|
"-"
|
||||||
|
"+"
|
||||||
|
] @operator)
|
||||||
|
|
||||||
|
(unary_expression
|
||||||
|
[
|
||||||
|
"delete"
|
||||||
|
"void"
|
||||||
|
] @keyword.operator)
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(template_substitution
|
||||||
|
[
|
||||||
|
"${"
|
||||||
|
"}"
|
||||||
|
] @punctuation.special) @none
|
||||||
|
|
||||||
|
; Imports
|
||||||
|
;----------
|
||||||
|
(namespace_import
|
||||||
|
"*" @character.special
|
||||||
|
(identifier) @module)
|
||||||
|
|
||||||
|
(namespace_export
|
||||||
|
"*" @character.special
|
||||||
|
(identifier) @module)
|
||||||
|
|
||||||
|
(export_statement
|
||||||
|
"*" @character.special)
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
;----------
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"else"
|
||||||
|
"switch"
|
||||||
|
"case"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"import"
|
||||||
|
"from"
|
||||||
|
"as"
|
||||||
|
"export"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"of"
|
||||||
|
"do"
|
||||||
|
"while"
|
||||||
|
"continue"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"const"
|
||||||
|
"debugger"
|
||||||
|
"extends"
|
||||||
|
"get"
|
||||||
|
"let"
|
||||||
|
"set"
|
||||||
|
"static"
|
||||||
|
"target"
|
||||||
|
"var"
|
||||||
|
"with"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
"class" @keyword.type
|
||||||
|
|
||||||
|
[
|
||||||
|
"async"
|
||||||
|
"await"
|
||||||
|
] @keyword.coroutine
|
||||||
|
|
||||||
|
[
|
||||||
|
"return"
|
||||||
|
"yield"
|
||||||
|
] @keyword.return
|
||||||
|
|
||||||
|
"function" @keyword.function
|
||||||
|
|
||||||
|
[
|
||||||
|
"new"
|
||||||
|
"delete"
|
||||||
|
"in"
|
||||||
|
"instanceof"
|
||||||
|
"typeof"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"throw"
|
||||||
|
"try"
|
||||||
|
"catch"
|
||||||
|
"finally"
|
||||||
|
] @keyword.exception
|
||||||
|
|
||||||
|
(export_statement
|
||||||
|
"default" @keyword)
|
||||||
|
|
||||||
|
(switch_default
|
||||||
|
"default" @keyword.conditional)
|
||||||
203
config/nvim/queries/ecma/injections.scm
Normal file
203
config/nvim/queries/ecma/injections.scm
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
(((comment) @_jsdoc_comment
|
||||||
|
(#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
|
||||||
|
(#set! injection.language "jsdoc"))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; html(`...`), html`...`, sql(`...`), etc.
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @injection.language
|
||||||
|
arguments: [
|
||||||
|
(arguments
|
||||||
|
(template_string) @injection.content)
|
||||||
|
(template_string) @injection.content
|
||||||
|
]
|
||||||
|
(#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
; Languages excluded from auto-injection due to special rules
|
||||||
|
; - svg uses the html parser
|
||||||
|
; - css uses the styled parser
|
||||||
|
(#not-any-of? @injection.language "svg" "css"))
|
||||||
|
|
||||||
|
; svg`...` or svg(`...`)
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "svg")
|
||||||
|
arguments: [
|
||||||
|
(arguments
|
||||||
|
(template_string) @injection.content)
|
||||||
|
(template_string) @injection.content
|
||||||
|
]
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "html"))
|
||||||
|
|
||||||
|
; Vercel PostgreSQL
|
||||||
|
; foo.sql`...` or foo.sql(`...`)
|
||||||
|
(call_expression
|
||||||
|
function: (member_expression
|
||||||
|
property: (property_identifier) @injection.language)
|
||||||
|
arguments: [
|
||||||
|
(arguments
|
||||||
|
(template_string) @injection.content)
|
||||||
|
(template_string) @injection.content
|
||||||
|
]
|
||||||
|
(#eq? @injection.language "sql")
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "gql")
|
||||||
|
arguments: (template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "graphql"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "hbs")
|
||||||
|
arguments: (template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "glimmer"))
|
||||||
|
|
||||||
|
; css`<css>`, keyframes`<css>`
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#any-of? @_name "css" "keyframes")
|
||||||
|
arguments: (template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "styled"))
|
||||||
|
|
||||||
|
; styled.div`<css>`
|
||||||
|
(call_expression
|
||||||
|
function: (member_expression
|
||||||
|
object: (identifier) @_name
|
||||||
|
(#eq? @_name "styled"))
|
||||||
|
arguments: ((template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
|
; styled(Component)`<css>`
|
||||||
|
(call_expression
|
||||||
|
function: (call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "styled"))
|
||||||
|
arguments: ((template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
|
; styled.div.attrs({ prop: "foo" })`<css>`
|
||||||
|
(call_expression
|
||||||
|
function: (call_expression
|
||||||
|
function: (member_expression
|
||||||
|
object: (member_expression
|
||||||
|
object: (identifier) @_name
|
||||||
|
(#eq? @_name "styled"))))
|
||||||
|
arguments: ((template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
|
; styled(Component).attrs({ prop: "foo" })`<css>`
|
||||||
|
(call_expression
|
||||||
|
function: (call_expression
|
||||||
|
function: (member_expression
|
||||||
|
object: (call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "styled"))))
|
||||||
|
arguments: ((template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
|
((regex_pattern) @injection.content
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
; ((comment) @_gql_comment
|
||||||
|
; (#eq? @_gql_comment "/* GraphQL */")
|
||||||
|
; (template_string) @injection.content
|
||||||
|
; (#set! injection.language "graphql"))
|
||||||
|
((template_string) @injection.content
|
||||||
|
(#lua-match? @injection.content "^`#graphql")
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "graphql"))
|
||||||
|
|
||||||
|
; el.innerHTML = `<html>`
|
||||||
|
(assignment_expression
|
||||||
|
left: (member_expression
|
||||||
|
property: (property_identifier) @_prop
|
||||||
|
(#any-of? @_prop "outerHTML" "innerHTML"))
|
||||||
|
right: (template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "html"))
|
||||||
|
|
||||||
|
; el.innerHTML = '<html>'
|
||||||
|
(assignment_expression
|
||||||
|
left: (member_expression
|
||||||
|
property: (property_identifier) @_prop
|
||||||
|
(#any-of? @_prop "outerHTML" "innerHTML"))
|
||||||
|
right: (string
|
||||||
|
(string_fragment) @injection.content)
|
||||||
|
(#set! injection.language "html"))
|
||||||
|
|
||||||
|
;---- Angular injections -----
|
||||||
|
; @Component({
|
||||||
|
; template: `<html>`
|
||||||
|
; })
|
||||||
|
(decorator
|
||||||
|
(call_expression
|
||||||
|
function: ((identifier) @_name
|
||||||
|
(#eq? @_name "Component"))
|
||||||
|
arguments: (arguments
|
||||||
|
(object
|
||||||
|
(pair
|
||||||
|
key: ((property_identifier) @_prop
|
||||||
|
(#eq? @_prop "template"))
|
||||||
|
value: ((template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "angular")))))))
|
||||||
|
|
||||||
|
; @Component({
|
||||||
|
; styles: [`<css>`]
|
||||||
|
; })
|
||||||
|
(decorator
|
||||||
|
(call_expression
|
||||||
|
function: ((identifier) @_name
|
||||||
|
(#eq? @_name "Component"))
|
||||||
|
arguments: (arguments
|
||||||
|
(object
|
||||||
|
(pair
|
||||||
|
key: ((property_identifier) @_prop
|
||||||
|
(#eq? @_prop "styles"))
|
||||||
|
value: (array
|
||||||
|
((template_string) @injection.content
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#set! injection.language "css"))))))))
|
||||||
|
|
||||||
|
; @Component({
|
||||||
|
; styles: `<css>`
|
||||||
|
; })
|
||||||
|
(decorator
|
||||||
|
(call_expression
|
||||||
|
function: ((identifier) @_name
|
||||||
|
(#eq? @_name "Component"))
|
||||||
|
arguments: (arguments
|
||||||
|
(object
|
||||||
|
(pair
|
||||||
|
key: ((property_identifier) @_prop
|
||||||
|
(#eq? @_prop "styles"))
|
||||||
|
value: ((template_string) @injection.content
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.language "css")))))))
|
||||||
42
config/nvim/queries/ecma/locals.scm
Normal file
42
config/nvim/queries/ecma/locals.scm
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
; Scopes
|
||||||
|
;-------
|
||||||
|
(statement_block) @local.scope
|
||||||
|
|
||||||
|
(function_expression) @local.scope
|
||||||
|
|
||||||
|
(arrow_function) @local.scope
|
||||||
|
|
||||||
|
(function_declaration) @local.scope
|
||||||
|
|
||||||
|
(method_definition) @local.scope
|
||||||
|
|
||||||
|
(for_statement) @local.scope
|
||||||
|
|
||||||
|
(for_in_statement) @local.scope
|
||||||
|
|
||||||
|
(catch_clause) @local.scope
|
||||||
|
|
||||||
|
; Definitions
|
||||||
|
;------------
|
||||||
|
(variable_declarator
|
||||||
|
name: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(import_specifier
|
||||||
|
(identifier) @local.definition.import)
|
||||||
|
|
||||||
|
(namespace_import
|
||||||
|
(identifier) @local.definition.import)
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
(identifier) @local.definition.function
|
||||||
|
(#set! definition.var.scope parent))
|
||||||
|
|
||||||
|
(method_definition
|
||||||
|
(property_identifier) @local.definition.function
|
||||||
|
(#set! definition.var.scope parent))
|
||||||
|
|
||||||
|
; References
|
||||||
|
;------------
|
||||||
|
(identifier) @local.reference
|
||||||
|
|
||||||
|
(shorthand_property_identifier) @local.reference
|
||||||
372
config/nvim/queries/ecma/textobjects.scm
Normal file
372
config/nvim/queries/ecma/textobjects.scm
Normal file
@@ -0,0 +1,372 @@
|
|||||||
|
(function_declaration
|
||||||
|
body: (statement_block)) @function.outer
|
||||||
|
|
||||||
|
(generator_function_declaration
|
||||||
|
body: (statement_block)) @function.outer
|
||||||
|
|
||||||
|
(function_expression
|
||||||
|
body: (statement_block)) @function.outer
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(generator_function_declaration
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(function_expression
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(export_statement
|
||||||
|
(function_declaration)) @function.outer
|
||||||
|
|
||||||
|
(arrow_function
|
||||||
|
body: (_) @function.inner) @function.outer
|
||||||
|
|
||||||
|
(arrow_function
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(method_definition
|
||||||
|
body: (statement_block)) @function.outer
|
||||||
|
|
||||||
|
(method_definition
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(class_declaration
|
||||||
|
body: (class_body)) @class.outer
|
||||||
|
|
||||||
|
(class_declaration
|
||||||
|
body: (class_body
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(export_statement
|
||||||
|
(class_declaration)) @class.outer
|
||||||
|
|
||||||
|
(for_in_statement
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(do_statement
|
||||||
|
body: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
consequence: (statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}")) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
alternative: (else_clause
|
||||||
|
(statement_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}"))) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement) @conditional.outer
|
||||||
|
|
||||||
|
(switch_statement
|
||||||
|
body: (_)? @conditional.inner) @conditional.outer
|
||||||
|
|
||||||
|
(call_expression) @call.outer
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(new_expression
|
||||||
|
constructor: (identifier) @call.outer
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")") @call.outer)
|
||||||
|
|
||||||
|
; blocks
|
||||||
|
(statement_block
|
||||||
|
(_)* @block.inner) @block.outer
|
||||||
|
|
||||||
|
; parameters
|
||||||
|
; function ({ x }) ...
|
||||||
|
; function ([ x ]) ...
|
||||||
|
; function (v = default_value)
|
||||||
|
(formal_parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element with trailing comma
|
||||||
|
(formal_parameters
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
; If the array/object pattern is the first parameter, treat its elements as the argument list
|
||||||
|
(formal_parameters
|
||||||
|
.
|
||||||
|
(_
|
||||||
|
[
|
||||||
|
(object_pattern
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
(array_pattern
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
]))
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
.
|
||||||
|
(_
|
||||||
|
[
|
||||||
|
(object_pattern
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
(array_pattern
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
]))
|
||||||
|
|
||||||
|
; last element with trailing comma
|
||||||
|
(formal_parameters
|
||||||
|
.
|
||||||
|
(_
|
||||||
|
[
|
||||||
|
(object_pattern
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
(array_pattern
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
]))
|
||||||
|
|
||||||
|
; arguments
|
||||||
|
(arguments
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(arguments
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element with trailing comma
|
||||||
|
(arguments
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
; comment
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
; regex
|
||||||
|
(regex
|
||||||
|
(regex_pattern) @regex.inner) @regex.outer
|
||||||
|
|
||||||
|
; number
|
||||||
|
(number) @number.inner
|
||||||
|
|
||||||
|
(lexical_declaration
|
||||||
|
(variable_declarator
|
||||||
|
name: (_) @assignment.lhs
|
||||||
|
value: (_) @assignment.inner @assignment.rhs)) @assignment.outer
|
||||||
|
|
||||||
|
(variable_declarator
|
||||||
|
name: (_) @assignment.inner)
|
||||||
|
|
||||||
|
(object
|
||||||
|
(pair
|
||||||
|
key: (_) @assignment.lhs
|
||||||
|
value: (_) @assignment.inner @assignment.rhs) @assignment.outer)
|
||||||
|
|
||||||
|
(return_statement
|
||||||
|
(_) @return.inner) @return.outer
|
||||||
|
|
||||||
|
(return_statement) @statement.outer
|
||||||
|
|
||||||
|
[
|
||||||
|
(if_statement)
|
||||||
|
(expression_statement)
|
||||||
|
(for_statement)
|
||||||
|
(while_statement)
|
||||||
|
(do_statement)
|
||||||
|
(for_in_statement)
|
||||||
|
(export_statement)
|
||||||
|
(lexical_declaration)
|
||||||
|
] @statement.outer
|
||||||
|
|
||||||
|
; 1. default import
|
||||||
|
(import_statement
|
||||||
|
(import_clause
|
||||||
|
(identifier) @parameter.inner @parameter.outer))
|
||||||
|
|
||||||
|
; 2. namespace import e.g. `* as React`
|
||||||
|
(import_statement
|
||||||
|
(import_clause
|
||||||
|
(namespace_import
|
||||||
|
(identifier) @parameter.inner) @parameter.outer))
|
||||||
|
|
||||||
|
; 3. named import e.g. `import { Bar, Baz } from ...`
|
||||||
|
(import_statement
|
||||||
|
(import_clause
|
||||||
|
(named_imports
|
||||||
|
(import_specifier) @parameter.inner)))
|
||||||
|
|
||||||
|
; 3‑A. named import followed by a comma
|
||||||
|
(import_statement
|
||||||
|
(import_clause
|
||||||
|
(named_imports
|
||||||
|
(import_specifier) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer)))
|
||||||
|
|
||||||
|
; 3‑B. comma followed by named import
|
||||||
|
(import_statement
|
||||||
|
(import_clause
|
||||||
|
(named_imports
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(import_specifier) @parameter.outer)))
|
||||||
|
|
||||||
|
; 3-C. only one named import without a comma
|
||||||
|
(import_statement
|
||||||
|
(import_clause
|
||||||
|
(named_imports
|
||||||
|
.
|
||||||
|
(import_specifier) @parameter.outer .)))
|
||||||
|
|
||||||
|
; Treat list or object elements as @parameter
|
||||||
|
; 1. parameter.inner
|
||||||
|
(object
|
||||||
|
(_) @parameter.inner)
|
||||||
|
|
||||||
|
(array
|
||||||
|
(_) @parameter.inner)
|
||||||
|
|
||||||
|
(object_pattern
|
||||||
|
(_) @parameter.inner)
|
||||||
|
|
||||||
|
(array_pattern
|
||||||
|
(_) @parameter.inner)
|
||||||
|
|
||||||
|
; 2. parameter.outer: Only one element, no comma
|
||||||
|
(object
|
||||||
|
.
|
||||||
|
(_) @parameter.outer .)
|
||||||
|
|
||||||
|
(array
|
||||||
|
.
|
||||||
|
(_) @parameter.outer .)
|
||||||
|
|
||||||
|
(object_pattern
|
||||||
|
.
|
||||||
|
(_) @parameter.outer .)
|
||||||
|
|
||||||
|
(array_pattern
|
||||||
|
.
|
||||||
|
(_) @parameter.outer .)
|
||||||
|
|
||||||
|
; 3. parameter.outer: Comma before or after
|
||||||
|
[
|
||||||
|
(object
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.outer)
|
||||||
|
(array
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.outer)
|
||||||
|
(object_pattern
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.outer)
|
||||||
|
(array_pattern
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.outer)
|
||||||
|
]
|
||||||
|
|
||||||
|
[
|
||||||
|
(object
|
||||||
|
.
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer)
|
||||||
|
(array
|
||||||
|
.
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer)
|
||||||
|
(object_pattern
|
||||||
|
.
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer)
|
||||||
|
(array_pattern
|
||||||
|
.
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer)
|
||||||
|
]
|
||||||
19
config/nvim/queries/go/folds.scm
Normal file
19
config/nvim/queries/go/folds.scm
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[
|
||||||
|
(const_declaration)
|
||||||
|
(expression_switch_statement)
|
||||||
|
(expression_case)
|
||||||
|
(default_case)
|
||||||
|
(type_switch_statement)
|
||||||
|
(type_case)
|
||||||
|
(for_statement)
|
||||||
|
(func_literal)
|
||||||
|
(function_declaration)
|
||||||
|
(if_statement)
|
||||||
|
(import_declaration)
|
||||||
|
(method_declaration)
|
||||||
|
(type_declaration)
|
||||||
|
(var_declaration)
|
||||||
|
(composite_literal)
|
||||||
|
(literal_element)
|
||||||
|
(block)
|
||||||
|
] @fold
|
||||||
254
config/nvim/queries/go/highlights.scm
Normal file
254
config/nvim/queries/go/highlights.scm
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
; Forked from tree-sitter-go
|
||||||
|
; Copyright (c) 2014 Max Brunsfeld (The MIT License)
|
||||||
|
;
|
||||||
|
; Identifiers
|
||||||
|
(type_identifier) @type
|
||||||
|
|
||||||
|
(type_spec
|
||||||
|
name: (type_identifier) @type.definition)
|
||||||
|
|
||||||
|
(field_identifier) @property
|
||||||
|
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
(package_identifier) @module
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(variadic_parameter_declaration
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(label_name) @label
|
||||||
|
|
||||||
|
(const_spec
|
||||||
|
name: (identifier) @constant)
|
||||||
|
|
||||||
|
; Function calls
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (selector_expression
|
||||||
|
field: (field_identifier) @function.method.call))
|
||||||
|
|
||||||
|
; Function definitions
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
(method_declaration
|
||||||
|
name: (field_identifier) @function.method)
|
||||||
|
|
||||||
|
(method_elem
|
||||||
|
name: (field_identifier) @function.method)
|
||||||
|
|
||||||
|
; Constructors
|
||||||
|
((call_expression
|
||||||
|
(identifier) @constructor)
|
||||||
|
(#lua-match? @constructor "^[nN]ew.+$"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
(identifier) @constructor)
|
||||||
|
(#lua-match? @constructor "^[mM]ake.+$"))
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
[
|
||||||
|
"--"
|
||||||
|
"-"
|
||||||
|
"-="
|
||||||
|
":="
|
||||||
|
"!"
|
||||||
|
"!="
|
||||||
|
"..."
|
||||||
|
"*"
|
||||||
|
"*"
|
||||||
|
"*="
|
||||||
|
"/"
|
||||||
|
"/="
|
||||||
|
"&"
|
||||||
|
"&&"
|
||||||
|
"&="
|
||||||
|
"&^"
|
||||||
|
"&^="
|
||||||
|
"%"
|
||||||
|
"%="
|
||||||
|
"^"
|
||||||
|
"^="
|
||||||
|
"+"
|
||||||
|
"++"
|
||||||
|
"+="
|
||||||
|
"<-"
|
||||||
|
"<"
|
||||||
|
"<<"
|
||||||
|
"<<="
|
||||||
|
"<="
|
||||||
|
"="
|
||||||
|
"=="
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
">>"
|
||||||
|
">>="
|
||||||
|
"|"
|
||||||
|
"|="
|
||||||
|
"||"
|
||||||
|
"~"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"const"
|
||||||
|
"continue"
|
||||||
|
"default"
|
||||||
|
"defer"
|
||||||
|
"goto"
|
||||||
|
"range"
|
||||||
|
"select"
|
||||||
|
"var"
|
||||||
|
"fallthrough"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"type"
|
||||||
|
"struct"
|
||||||
|
"interface"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
"func" @keyword.function
|
||||||
|
|
||||||
|
"return" @keyword.return
|
||||||
|
|
||||||
|
"go" @keyword.coroutine
|
||||||
|
|
||||||
|
"for" @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"import"
|
||||||
|
"package"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
"else"
|
||||||
|
"case"
|
||||||
|
"switch"
|
||||||
|
"if"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
; Builtin types
|
||||||
|
[
|
||||||
|
"chan"
|
||||||
|
"map"
|
||||||
|
] @type.builtin
|
||||||
|
|
||||||
|
((type_identifier) @type.builtin
|
||||||
|
(#any-of? @type.builtin
|
||||||
|
"any" "bool" "byte" "comparable" "complex128" "complex64" "error" "float32" "float64" "int"
|
||||||
|
"int16" "int32" "int64" "int8" "rune" "string" "uint" "uint16" "uint32" "uint64" "uint8"
|
||||||
|
"uintptr"))
|
||||||
|
|
||||||
|
; Builtin functions
|
||||||
|
((identifier) @function.builtin
|
||||||
|
(#any-of? @function.builtin
|
||||||
|
"append" "cap" "clear" "close" "complex" "copy" "delete" "imag" "len" "make" "max" "min" "new"
|
||||||
|
"panic" "print" "println" "real" "recover"))
|
||||||
|
|
||||||
|
; Delimiters
|
||||||
|
"." @punctuation.delimiter
|
||||||
|
|
||||||
|
"," @punctuation.delimiter
|
||||||
|
|
||||||
|
":" @punctuation.delimiter
|
||||||
|
|
||||||
|
";" @punctuation.delimiter
|
||||||
|
|
||||||
|
"(" @punctuation.bracket
|
||||||
|
|
||||||
|
")" @punctuation.bracket
|
||||||
|
|
||||||
|
"{" @punctuation.bracket
|
||||||
|
|
||||||
|
"}" @punctuation.bracket
|
||||||
|
|
||||||
|
"[" @punctuation.bracket
|
||||||
|
|
||||||
|
"]" @punctuation.bracket
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
(interpreted_string_literal) @string
|
||||||
|
|
||||||
|
(raw_string_literal) @string
|
||||||
|
|
||||||
|
(rune_literal) @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
(int_literal) @number
|
||||||
|
|
||||||
|
(float_literal) @number.float
|
||||||
|
|
||||||
|
(imaginary_literal) @number
|
||||||
|
|
||||||
|
[
|
||||||
|
(true)
|
||||||
|
(false)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
[
|
||||||
|
(nil)
|
||||||
|
(iota)
|
||||||
|
] @constant.builtin
|
||||||
|
|
||||||
|
(keyed_element
|
||||||
|
.
|
||||||
|
(literal_element
|
||||||
|
(identifier) @variable.member))
|
||||||
|
|
||||||
|
(field_declaration
|
||||||
|
name: (field_identifier) @variable.member)
|
||||||
|
|
||||||
|
; Comments
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
; Doc Comments
|
||||||
|
(source_file
|
||||||
|
.
|
||||||
|
(comment)+ @comment.documentation)
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(comment)+ @comment.documentation
|
||||||
|
.
|
||||||
|
(const_declaration))
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(comment)+ @comment.documentation
|
||||||
|
.
|
||||||
|
(function_declaration))
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(comment)+ @comment.documentation
|
||||||
|
.
|
||||||
|
(type_declaration))
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(comment)+ @comment.documentation
|
||||||
|
.
|
||||||
|
(var_declaration))
|
||||||
|
|
||||||
|
; Spell
|
||||||
|
((interpreted_string_literal) @spell
|
||||||
|
(#not-has-parent? @spell import_spec))
|
||||||
|
|
||||||
|
; Regex
|
||||||
|
(call_expression
|
||||||
|
(selector_expression) @_function
|
||||||
|
(#any-of? @_function
|
||||||
|
"regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX"
|
||||||
|
"regexp.MustCompile" "regexp.MustCompilePOSIX")
|
||||||
|
(argument_list
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(raw_string_literal
|
||||||
|
(raw_string_literal_content) @string.regexp)
|
||||||
|
(interpreted_string_literal
|
||||||
|
(interpreted_string_literal_content) @string.regexp)
|
||||||
|
]))
|
||||||
42
config/nvim/queries/go/injections.scm
Normal file
42
config/nvim/queries/go/injections.scm
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
(selector_expression) @_function
|
||||||
|
(#any-of? @_function
|
||||||
|
"regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX"
|
||||||
|
"regexp.MustCompile" "regexp.MustCompilePOSIX")
|
||||||
|
(argument_list
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(raw_string_literal
|
||||||
|
(raw_string_literal_content) @injection.content)
|
||||||
|
(interpreted_string_literal
|
||||||
|
(interpreted_string_literal_content) @injection.content)
|
||||||
|
]
|
||||||
|
(#set! injection.language "regex")))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||||
|
(#set! injection.language "re2c"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (selector_expression
|
||||||
|
field: (field_identifier) @_method)
|
||||||
|
arguments: (argument_list
|
||||||
|
.
|
||||||
|
(interpreted_string_literal
|
||||||
|
(interpreted_string_literal_content) @injection.content)))
|
||||||
|
(#any-of? @_method "Printf" "Sprintf" "Fatalf" "Scanf" "Errorf" "Skipf" "Logf")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (selector_expression
|
||||||
|
field: (field_identifier) @_method)
|
||||||
|
arguments: (argument_list
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(interpreted_string_literal
|
||||||
|
(interpreted_string_literal_content) @injection.content)))
|
||||||
|
(#any-of? @_method "Fprintf" "Fscanf" "Appendf" "Sscanf")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
88
config/nvim/queries/go/locals.scm
Normal file
88
config/nvim/queries/go/locals.scm
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
((function_declaration
|
||||||
|
name: (identifier) @local.definition.function) ; @function
|
||||||
|
)
|
||||||
|
|
||||||
|
((method_declaration
|
||||||
|
name: (field_identifier) @local.definition.method) ; @function.method
|
||||||
|
)
|
||||||
|
|
||||||
|
(short_var_declaration
|
||||||
|
left: (expression_list
|
||||||
|
(identifier) @local.definition.var))
|
||||||
|
|
||||||
|
(var_spec
|
||||||
|
name: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(variadic_parameter_declaration
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
(range_clause
|
||||||
|
left: (expression_list
|
||||||
|
(identifier) @local.definition.var)))
|
||||||
|
|
||||||
|
(const_declaration
|
||||||
|
(const_spec
|
||||||
|
name: (identifier) @local.definition.var))
|
||||||
|
|
||||||
|
(type_declaration
|
||||||
|
(type_spec
|
||||||
|
name: (type_identifier) @local.definition.type))
|
||||||
|
|
||||||
|
; reference
|
||||||
|
(identifier) @local.reference
|
||||||
|
|
||||||
|
(type_identifier) @local.reference
|
||||||
|
|
||||||
|
(field_identifier) @local.reference
|
||||||
|
|
||||||
|
((package_identifier) @local.reference
|
||||||
|
(#set! reference.kind "namespace"))
|
||||||
|
|
||||||
|
(package_clause
|
||||||
|
(package_identifier) @local.definition.namespace)
|
||||||
|
|
||||||
|
(import_spec_list
|
||||||
|
(import_spec
|
||||||
|
name: (package_identifier) @local.definition.namespace))
|
||||||
|
|
||||||
|
; Call references
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @local.reference)
|
||||||
|
(#set! reference.kind "call"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (selector_expression
|
||||||
|
field: (field_identifier) @local.reference))
|
||||||
|
(#set! reference.kind "call"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (parenthesized_expression
|
||||||
|
(identifier) @local.reference))
|
||||||
|
(#set! reference.kind "call"))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (parenthesized_expression
|
||||||
|
(selector_expression
|
||||||
|
field: (field_identifier) @local.reference)))
|
||||||
|
(#set! reference.kind "call"))
|
||||||
|
|
||||||
|
; Scopes
|
||||||
|
(func_literal) @local.scope
|
||||||
|
|
||||||
|
(source_file) @local.scope
|
||||||
|
|
||||||
|
(function_declaration) @local.scope
|
||||||
|
|
||||||
|
(if_statement) @local.scope
|
||||||
|
|
||||||
|
(block) @local.scope
|
||||||
|
|
||||||
|
(expression_switch_statement) @local.scope
|
||||||
|
|
||||||
|
(for_statement) @local.scope
|
||||||
|
|
||||||
|
(method_declaration) @local.scope
|
||||||
153
config/nvim/queries/go/textobjects.scm
Normal file
153
config/nvim/queries/go/textobjects.scm
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
; inner function textobject
|
||||||
|
(function_declaration
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; inner function literals
|
||||||
|
(func_literal
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; method as inner function textobject
|
||||||
|
(method_declaration
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; outer function textobject
|
||||||
|
(function_declaration) @function.outer
|
||||||
|
|
||||||
|
; outer function literals
|
||||||
|
(func_literal
|
||||||
|
(_)?) @function.outer
|
||||||
|
|
||||||
|
; method as outer function textobject
|
||||||
|
(method_declaration
|
||||||
|
body: (block)?) @function.outer
|
||||||
|
|
||||||
|
; struct and interface declaration as class textobject?
|
||||||
|
(type_declaration
|
||||||
|
(type_spec
|
||||||
|
(type_identifier)
|
||||||
|
(struct_type
|
||||||
|
(field_declaration_list
|
||||||
|
(_)?) @class.inner))) @class.outer
|
||||||
|
|
||||||
|
(type_declaration
|
||||||
|
(type_spec
|
||||||
|
(type_identifier)
|
||||||
|
(interface_type) @class.inner)) @class.outer
|
||||||
|
|
||||||
|
; struct literals as class textobject
|
||||||
|
(composite_literal
|
||||||
|
(type_identifier)?
|
||||||
|
(struct_type
|
||||||
|
(_))?
|
||||||
|
(literal_value
|
||||||
|
(_)) @class.inner) @class.outer
|
||||||
|
|
||||||
|
; conditionals
|
||||||
|
(if_statement
|
||||||
|
alternative: (_
|
||||||
|
(_) @conditional.inner)?) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
consequence: (block)? @conditional.inner)
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
; loops
|
||||||
|
(for_statement
|
||||||
|
body: (block)? @loop.inner) @loop.outer
|
||||||
|
|
||||||
|
; blocks
|
||||||
|
(_
|
||||||
|
(block) @block.inner) @block.outer
|
||||||
|
|
||||||
|
; statements
|
||||||
|
(block
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
; comments
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
; calls
|
||||||
|
(call_expression) @call.outer
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
arguments: (argument_list
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
; parameters
|
||||||
|
(parameter_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(parameter_declaration) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(parameter_list
|
||||||
|
.
|
||||||
|
(parameter_declaration) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
name: (identifier)
|
||||||
|
type: (_)) @parameter.inner
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
name: (identifier)
|
||||||
|
type: (_)) @parameter.inner
|
||||||
|
|
||||||
|
(parameter_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(variadic_parameter_declaration) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
; arguments
|
||||||
|
(argument_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(argument_list
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; assignments
|
||||||
|
(short_var_declaration
|
||||||
|
left: (_) @assignment.lhs
|
||||||
|
right: (_) @assignment.rhs @assignment.inner) @assignment.outer
|
||||||
|
|
||||||
|
(assignment_statement
|
||||||
|
left: (_) @assignment.lhs
|
||||||
|
right: (_) @assignment.rhs @assignment.inner) @assignment.outer
|
||||||
|
|
||||||
|
(var_spec
|
||||||
|
name: (_) @assignment.lhs
|
||||||
|
value: (_) @assignment.rhs @assignment.inner) @assignment.outer
|
||||||
|
|
||||||
|
(var_spec
|
||||||
|
name: (_) @assignment.inner
|
||||||
|
type: (_)) @assignment.outer
|
||||||
|
|
||||||
|
(const_spec
|
||||||
|
name: (_) @assignment.lhs
|
||||||
|
value: (_) @assignment.rhs @assignment.inner) @assignment.outer
|
||||||
|
|
||||||
|
(const_spec
|
||||||
|
name: (_) @assignment.inner
|
||||||
|
type: (_)) @assignment.outer
|
||||||
55
config/nvim/queries/goon/highlights.scm
Normal file
55
config/nvim/queries/goon/highlights.scm
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
; Keywords
|
||||||
|
"let" @keyword
|
||||||
|
"if" @keyword.conditional
|
||||||
|
"then" @keyword.conditional
|
||||||
|
"else" @keyword.conditional
|
||||||
|
"import" @keyword.import
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
(string) @string
|
||||||
|
(string_content) @string
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
(number) @number
|
||||||
|
(boolean) @boolean
|
||||||
|
|
||||||
|
; Identifiers
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
; Types
|
||||||
|
(type_annotation) @type
|
||||||
|
|
||||||
|
; Fields
|
||||||
|
(record_field
|
||||||
|
key: (identifier) @property)
|
||||||
|
|
||||||
|
(field_access
|
||||||
|
(identifier) @property)
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
"=" @operator
|
||||||
|
":" @punctuation.delimiter
|
||||||
|
"?" @operator
|
||||||
|
"..." @operator
|
||||||
|
"." @punctuation.delimiter
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
|
"{" @punctuation.bracket
|
||||||
|
"}" @punctuation.bracket
|
||||||
|
"[" @punctuation.bracket
|
||||||
|
"]" @punctuation.bracket
|
||||||
|
"(" @punctuation.bracket
|
||||||
|
")" @punctuation.bracket
|
||||||
|
";" @punctuation.delimiter
|
||||||
|
"," @punctuation.delimiter
|
||||||
|
|
||||||
|
; Interpolation
|
||||||
|
(interpolation
|
||||||
|
"${" @punctuation.special
|
||||||
|
"}" @punctuation.special)
|
||||||
|
|
||||||
|
; Comments
|
||||||
|
(comment) @comment
|
||||||
1
config/nvim/queries/javascript/folds.scm
Normal file
1
config/nvim/queries/javascript/folds.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits: ecma,jsx
|
||||||
56
config/nvim/queries/javascript/highlights.scm
Normal file
56
config/nvim/queries/javascript/highlights.scm
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
; inherits: ecma,jsx
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
(formal_parameters
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
(rest_pattern
|
||||||
|
(identifier) @variable.parameter))
|
||||||
|
|
||||||
|
; ({ a }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(object_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @variable.parameter))
|
||||||
|
|
||||||
|
; ({ a = b }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(object_pattern
|
||||||
|
(object_assignment_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @variable.parameter)))
|
||||||
|
|
||||||
|
; ({ a: b }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(object_pattern
|
||||||
|
(pair_pattern
|
||||||
|
value: (identifier) @variable.parameter)))
|
||||||
|
|
||||||
|
; ([ a ]) => null
|
||||||
|
(formal_parameters
|
||||||
|
(array_pattern
|
||||||
|
(identifier) @variable.parameter))
|
||||||
|
|
||||||
|
; ({ a } = { a }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(assignment_pattern
|
||||||
|
(object_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @variable.parameter)))
|
||||||
|
|
||||||
|
; ({ a = b } = { a }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(assignment_pattern
|
||||||
|
(object_pattern
|
||||||
|
(object_assignment_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @variable.parameter))))
|
||||||
|
|
||||||
|
; a => null
|
||||||
|
(arrow_function
|
||||||
|
parameter: (identifier) @variable.parameter)
|
||||||
|
|
||||||
|
; optional parameters
|
||||||
|
(formal_parameters
|
||||||
|
(assignment_pattern
|
||||||
|
left: (identifier) @variable.parameter))
|
||||||
|
|
||||||
|
; punctuation
|
||||||
|
(optional_chain) @punctuation.delimiter
|
||||||
1
config/nvim/queries/javascript/injections.scm
Normal file
1
config/nvim/queries/javascript/injections.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits: ecma,jsx
|
||||||
69
config/nvim/queries/javascript/locals.scm
Normal file
69
config/nvim/queries/javascript/locals.scm
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
; inherits: ecma,jsx
|
||||||
|
|
||||||
|
; Both properties are matched here.
|
||||||
|
;
|
||||||
|
; class Foo {
|
||||||
|
; this.#bar = "baz";
|
||||||
|
; this.quuz = "qux";
|
||||||
|
; }
|
||||||
|
(field_definition
|
||||||
|
property: [
|
||||||
|
(property_identifier)
|
||||||
|
(private_property_identifier)
|
||||||
|
] @local.definition.var)
|
||||||
|
|
||||||
|
; this.foo = "bar"
|
||||||
|
(assignment_expression
|
||||||
|
left: (member_expression
|
||||||
|
object: (this)
|
||||||
|
property: (property_identifier) @local.definition.var))
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
(identifier) @local.definition.parameter)
|
||||||
|
|
||||||
|
; function(arg = []) {
|
||||||
|
(formal_parameters
|
||||||
|
(assignment_pattern
|
||||||
|
left: (identifier) @local.definition.parameter))
|
||||||
|
|
||||||
|
; x => x
|
||||||
|
(arrow_function
|
||||||
|
parameter: (identifier) @local.definition.parameter)
|
||||||
|
|
||||||
|
; ({ a }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(object_pattern
|
||||||
|
(shorthand_property_identifier_pattern) @local.definition.parameter))
|
||||||
|
|
||||||
|
; ({ a: b }) => null
|
||||||
|
(formal_parameters
|
||||||
|
(object_pattern
|
||||||
|
(pair_pattern
|
||||||
|
value: (identifier) @local.definition.parameter)))
|
||||||
|
|
||||||
|
; ([ a ]) => null
|
||||||
|
(formal_parameters
|
||||||
|
(array_pattern
|
||||||
|
(identifier) @local.definition.parameter))
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
(rest_pattern
|
||||||
|
(identifier) @local.definition.parameter))
|
||||||
|
|
||||||
|
; Both methods are matched here.
|
||||||
|
;
|
||||||
|
; class Foo {
|
||||||
|
; #bar(x) { x }
|
||||||
|
; baz(y) { y }
|
||||||
|
; }
|
||||||
|
(method_definition
|
||||||
|
[
|
||||||
|
(property_identifier)
|
||||||
|
(private_property_identifier)
|
||||||
|
] @local.definition.function
|
||||||
|
(#set! definition.var.scope parent))
|
||||||
|
|
||||||
|
; this.foo()
|
||||||
|
(member_expression
|
||||||
|
object: (this)
|
||||||
|
property: (property_identifier) @local.reference)
|
||||||
1
config/nvim/queries/javascript/textobjects.scm
Normal file
1
config/nvim/queries/javascript/textobjects.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits: ecma,jsx
|
||||||
1
config/nvim/queries/jsx/folds.scm
Normal file
1
config/nvim/queries/jsx/folds.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(jsx_element) @fold
|
||||||
157
config/nvim/queries/jsx/highlights.scm
Normal file
157
config/nvim/queries/jsx/highlights.scm
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
(jsx_element
|
||||||
|
open_tag: (jsx_opening_element
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @tag.delimiter))
|
||||||
|
|
||||||
|
(jsx_element
|
||||||
|
close_tag: (jsx_closing_element
|
||||||
|
[
|
||||||
|
"</"
|
||||||
|
">"
|
||||||
|
] @tag.delimiter))
|
||||||
|
|
||||||
|
(jsx_self_closing_element
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
"/>"
|
||||||
|
] @tag.delimiter)
|
||||||
|
|
||||||
|
(jsx_attribute
|
||||||
|
(property_identifier) @tag.attribute)
|
||||||
|
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @tag.builtin)
|
||||||
|
|
||||||
|
(jsx_closing_element
|
||||||
|
name: (identifier) @tag.builtin)
|
||||||
|
|
||||||
|
(jsx_self_closing_element
|
||||||
|
name: (identifier) @tag.builtin)
|
||||||
|
|
||||||
|
(jsx_opening_element
|
||||||
|
((identifier) @tag
|
||||||
|
(#lua-match? @tag "^[A-Z]")))
|
||||||
|
|
||||||
|
; Handle the dot operator effectively - <My.Component>
|
||||||
|
(jsx_opening_element
|
||||||
|
(member_expression
|
||||||
|
(identifier) @tag.builtin
|
||||||
|
(property_identifier) @tag))
|
||||||
|
|
||||||
|
(jsx_closing_element
|
||||||
|
((identifier) @tag
|
||||||
|
(#lua-match? @tag "^[A-Z]")))
|
||||||
|
|
||||||
|
; Handle the dot operator effectively - </My.Component>
|
||||||
|
(jsx_closing_element
|
||||||
|
(member_expression
|
||||||
|
(identifier) @tag.builtin
|
||||||
|
(property_identifier) @tag))
|
||||||
|
|
||||||
|
(jsx_self_closing_element
|
||||||
|
((identifier) @tag
|
||||||
|
(#lua-match? @tag "^[A-Z]")))
|
||||||
|
|
||||||
|
; Handle the dot operator effectively - <My.Component />
|
||||||
|
(jsx_self_closing_element
|
||||||
|
(member_expression
|
||||||
|
(identifier) @tag.builtin
|
||||||
|
(property_identifier) @tag))
|
||||||
|
|
||||||
|
(html_character_reference) @tag
|
||||||
|
|
||||||
|
(jsx_text) @none @spell
|
||||||
|
|
||||||
|
(html_character_reference) @character.special
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading)
|
||||||
|
(#eq? @_tag "title"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading.1)
|
||||||
|
(#eq? @_tag "h1"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading.2)
|
||||||
|
(#eq? @_tag "h2"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading.3)
|
||||||
|
(#eq? @_tag "h3"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading.4)
|
||||||
|
(#eq? @_tag "h4"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading.5)
|
||||||
|
(#eq? @_tag "h5"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.heading.6)
|
||||||
|
(#eq? @_tag "h6"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.strong)
|
||||||
|
(#any-of? @_tag "strong" "b"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.italic)
|
||||||
|
(#any-of? @_tag "em" "i"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.strikethrough)
|
||||||
|
(#any-of? @_tag "s" "del"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.underline)
|
||||||
|
(#eq? @_tag "u"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.raw)
|
||||||
|
(#any-of? @_tag "code" "kbd"))
|
||||||
|
|
||||||
|
((jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
name: (identifier) @_tag)
|
||||||
|
(jsx_text) @markup.link.label)
|
||||||
|
(#eq? @_tag "a"))
|
||||||
|
|
||||||
|
((jsx_attribute
|
||||||
|
(property_identifier) @_attr
|
||||||
|
(string
|
||||||
|
(string_fragment) @string.special.url))
|
||||||
|
(#any-of? @_attr "href" "src"))
|
||||||
|
|
||||||
|
((jsx_element) @_jsx_element
|
||||||
|
(#set! @_jsx_element bo.commentstring "{/* %s */}"))
|
||||||
|
|
||||||
|
((jsx_attribute) @_jsx_attribute
|
||||||
|
(#set! @_jsx_attribute bo.commentstring "// %s"))
|
||||||
11
config/nvim/queries/jsx/injections.scm
Normal file
11
config/nvim/queries/jsx/injections.scm
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
; Styled Jsx <style jsx>
|
||||||
|
(jsx_element
|
||||||
|
(jsx_opening_element
|
||||||
|
(identifier) @_name
|
||||||
|
(#eq? @_name "style")
|
||||||
|
(jsx_attribute) @_attr
|
||||||
|
(#eq? @_attr "jsx"))
|
||||||
|
(jsx_expression
|
||||||
|
((template_string) @injection.content
|
||||||
|
(#set! injection.language "css"))
|
||||||
|
(#offset! @injection.content 0 1 0 -1)))
|
||||||
8
config/nvim/queries/jsx/textobjects.scm
Normal file
8
config/nvim/queries/jsx/textobjects.scm
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
; inherits: ecma
|
||||||
|
|
||||||
|
(jsx_attribute) @attribute.outer
|
||||||
|
|
||||||
|
(jsx_attribute
|
||||||
|
(property_identifier)
|
||||||
|
(_
|
||||||
|
(_) @attribute.inner))
|
||||||
12
config/nvim/queries/lua/folds.scm
Normal file
12
config/nvim/queries/lua/folds.scm
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[
|
||||||
|
(do_statement)
|
||||||
|
(while_statement)
|
||||||
|
(repeat_statement)
|
||||||
|
(if_statement)
|
||||||
|
(for_statement)
|
||||||
|
(function_declaration)
|
||||||
|
(function_definition)
|
||||||
|
(parameters)
|
||||||
|
(arguments)
|
||||||
|
(table_constructor)
|
||||||
|
] @fold
|
||||||
265
config/nvim/queries/lua/highlights.scm
Normal file
265
config/nvim/queries/lua/highlights.scm
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
; Keywords
|
||||||
|
"return" @keyword.return
|
||||||
|
|
||||||
|
[
|
||||||
|
"goto"
|
||||||
|
"in"
|
||||||
|
"local"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
(break_statement) @keyword
|
||||||
|
|
||||||
|
(do_statement
|
||||||
|
[
|
||||||
|
"do"
|
||||||
|
"end"
|
||||||
|
] @keyword)
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
[
|
||||||
|
"while"
|
||||||
|
"do"
|
||||||
|
"end"
|
||||||
|
] @keyword.repeat)
|
||||||
|
|
||||||
|
(repeat_statement
|
||||||
|
[
|
||||||
|
"repeat"
|
||||||
|
"until"
|
||||||
|
] @keyword.repeat)
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"elseif"
|
||||||
|
"else"
|
||||||
|
"then"
|
||||||
|
"end"
|
||||||
|
] @keyword.conditional)
|
||||||
|
|
||||||
|
(elseif_statement
|
||||||
|
[
|
||||||
|
"elseif"
|
||||||
|
"then"
|
||||||
|
"end"
|
||||||
|
] @keyword.conditional)
|
||||||
|
|
||||||
|
(else_statement
|
||||||
|
[
|
||||||
|
"else"
|
||||||
|
"end"
|
||||||
|
] @keyword.conditional)
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"do"
|
||||||
|
"end"
|
||||||
|
] @keyword.repeat)
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
[
|
||||||
|
"function"
|
||||||
|
"end"
|
||||||
|
] @keyword.function)
|
||||||
|
|
||||||
|
(function_definition
|
||||||
|
[
|
||||||
|
"function"
|
||||||
|
"end"
|
||||||
|
] @keyword.function)
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
[
|
||||||
|
"and"
|
||||||
|
"not"
|
||||||
|
"or"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"+"
|
||||||
|
"-"
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
|
"^"
|
||||||
|
"#"
|
||||||
|
"=="
|
||||||
|
"~="
|
||||||
|
"<="
|
||||||
|
">="
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
"="
|
||||||
|
"&"
|
||||||
|
"~"
|
||||||
|
"|"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"//"
|
||||||
|
".."
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Punctuations
|
||||||
|
[
|
||||||
|
";"
|
||||||
|
":"
|
||||||
|
"::"
|
||||||
|
","
|
||||||
|
"."
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
; Brackets
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
; Variables
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
((identifier) @constant.builtin
|
||||||
|
(#eq? @constant.builtin "_VERSION"))
|
||||||
|
|
||||||
|
((identifier) @variable.builtin
|
||||||
|
(#eq? @variable.builtin "self"))
|
||||||
|
|
||||||
|
((identifier) @module.builtin
|
||||||
|
(#any-of? @module.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
|
||||||
|
|
||||||
|
((identifier) @keyword.coroutine
|
||||||
|
(#eq? @keyword.coroutine "coroutine"))
|
||||||
|
|
||||||
|
(variable_list
|
||||||
|
(attribute
|
||||||
|
"<" @punctuation.bracket
|
||||||
|
(identifier) @attribute
|
||||||
|
">" @punctuation.bracket))
|
||||||
|
|
||||||
|
; Labels
|
||||||
|
(label_statement
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
(goto_statement
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
; Constants
|
||||||
|
((identifier) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||||
|
|
||||||
|
(nil) @constant.builtin
|
||||||
|
|
||||||
|
[
|
||||||
|
(false)
|
||||||
|
(true)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
; Tables
|
||||||
|
(field
|
||||||
|
name: (identifier) @property)
|
||||||
|
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @variable.member)
|
||||||
|
|
||||||
|
(table_constructor
|
||||||
|
[
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @constructor)
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
(parameters
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(vararg_expression) @variable.parameter.builtin
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
name: [
|
||||||
|
(identifier) @function
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @function)
|
||||||
|
])
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
name: (method_index_expression
|
||||||
|
method: (identifier) @function.method))
|
||||||
|
|
||||||
|
(assignment_statement
|
||||||
|
(variable_list
|
||||||
|
.
|
||||||
|
name: [
|
||||||
|
(identifier) @function
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @function)
|
||||||
|
])
|
||||||
|
(expression_list
|
||||||
|
.
|
||||||
|
value: (function_definition)))
|
||||||
|
|
||||||
|
(table_constructor
|
||||||
|
(field
|
||||||
|
name: (identifier) @function
|
||||||
|
value: (function_definition)))
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
name: [
|
||||||
|
(identifier) @function.call
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @function.call)
|
||||||
|
(method_index_expression
|
||||||
|
method: (identifier) @function.method.call)
|
||||||
|
])
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
(identifier) @function.builtin
|
||||||
|
(#any-of? @function.builtin
|
||||||
|
; built-in functions in Lua 5.1
|
||||||
|
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
|
||||||
|
"loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset"
|
||||||
|
"require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"
|
||||||
|
"__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc" "__idiv"
|
||||||
|
"__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" "__pairs"
|
||||||
|
"__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
|
||||||
|
|
||||||
|
; Others
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
((comment) @comment.documentation
|
||||||
|
(#lua-match? @comment.documentation "^[-][-][-]"))
|
||||||
|
|
||||||
|
((comment) @comment.documentation
|
||||||
|
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
||||||
|
|
||||||
|
(hash_bang_line) @keyword.directive
|
||||||
|
|
||||||
|
(number) @number
|
||||||
|
|
||||||
|
(string) @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
; string.match("123", "%d+")
|
||||||
|
(function_call
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @_method
|
||||||
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: (string_content) @string.regexp)))
|
||||||
|
|
||||||
|
;("123"):match("%d+")
|
||||||
|
(function_call
|
||||||
|
(method_index_expression
|
||||||
|
method: (identifier) @_method
|
||||||
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: (string_content) @string.regexp)))
|
||||||
202
config/nvim/queries/lua/injections.scm
Normal file
202
config/nvim/queries/lua/injections.scm
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
((function_call
|
||||||
|
name: [
|
||||||
|
(identifier) @_cdef_identifier
|
||||||
|
(_
|
||||||
|
_
|
||||||
|
(identifier) @_cdef_identifier)
|
||||||
|
]
|
||||||
|
arguments: (arguments
|
||||||
|
(string
|
||||||
|
content: _ @injection.content)))
|
||||||
|
(#set! injection.language "c")
|
||||||
|
(#eq? @_cdef_identifier "cdef"))
|
||||||
|
|
||||||
|
((function_call
|
||||||
|
name: (_) @_vimcmd_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
(string
|
||||||
|
content: _ @injection.content)))
|
||||||
|
(#set! injection.language "vim")
|
||||||
|
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2"))
|
||||||
|
|
||||||
|
((function_call
|
||||||
|
name: (_) @_vimcmd_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
(string
|
||||||
|
content: _ @injection.content) .))
|
||||||
|
(#set! injection.language "query")
|
||||||
|
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
|
||||||
|
|
||||||
|
((function_call
|
||||||
|
name: (_) @_vimcmd_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: _ @_method)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: _ @injection.content)))
|
||||||
|
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
|
||||||
|
(#eq? @_method "nvim_exec_lua")
|
||||||
|
(#set! injection.language "lua"))
|
||||||
|
|
||||||
|
; exec_lua [[ ... ]] in functionaltests
|
||||||
|
((function_call
|
||||||
|
name: (identifier) @_function
|
||||||
|
arguments: (arguments
|
||||||
|
(string
|
||||||
|
content: (string_content) @injection.content)))
|
||||||
|
(#eq? @_function "exec_lua")
|
||||||
|
(#set! injection.language "lua"))
|
||||||
|
|
||||||
|
; vim.api.nvim_create_autocmd("FileType", { command = "injected here" })
|
||||||
|
(function_call
|
||||||
|
name: (_) @_vimcmd_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(table_constructor
|
||||||
|
(field
|
||||||
|
name: (identifier) @_command
|
||||||
|
value: (string
|
||||||
|
content: (_) @injection.content))) .)
|
||||||
|
; limit so only 2-argument functions gets matched before pred handle
|
||||||
|
(#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd")
|
||||||
|
(#eq? @_command "command")
|
||||||
|
(#set! injection.language "vim"))
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
name: (_) @_user_cmd
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: (_) @injection.content)
|
||||||
|
.
|
||||||
|
(_) .)
|
||||||
|
(#eq? @_user_cmd "vim.api.nvim_create_user_command")
|
||||||
|
(#set! injection.language "vim"))
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
name: (_) @_user_cmd
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: (_) @injection.content)
|
||||||
|
.
|
||||||
|
(_) .)
|
||||||
|
; Limiting predicate handling to only functions with 4 arguments
|
||||||
|
(#eq? @_user_cmd "vim.api.nvim_buf_create_user_command")
|
||||||
|
(#set! injection.language "vim"))
|
||||||
|
|
||||||
|
; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap
|
||||||
|
; (function_call
|
||||||
|
; name: (_) @_map
|
||||||
|
; arguments:
|
||||||
|
; (arguments
|
||||||
|
; . (_)
|
||||||
|
; . (_)
|
||||||
|
; .
|
||||||
|
; (string
|
||||||
|
; content: (_) @injection.content))
|
||||||
|
; (#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set")
|
||||||
|
; (#set! injection.language "vim"))
|
||||||
|
;
|
||||||
|
; (function_call
|
||||||
|
; name: (_) @_map
|
||||||
|
; arguments:
|
||||||
|
; (arguments
|
||||||
|
; . (_)
|
||||||
|
; . (_)
|
||||||
|
; . (_)
|
||||||
|
; .
|
||||||
|
; (string
|
||||||
|
; content: (_) @injection.content)
|
||||||
|
; . (_) .)
|
||||||
|
; (#eq? @_map "vim.api.nvim_buf_set_keymap")
|
||||||
|
; (#set! injection.language "vim"))
|
||||||
|
; highlight string as query if starts with `;; query`
|
||||||
|
(string
|
||||||
|
content: _ @injection.content
|
||||||
|
(#lua-match? @injection.content "^%s*;+%s?query")
|
||||||
|
(#set! injection.language "query"))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
content: (_) @injection.content
|
||||||
|
(#lua-match? @injection.content "^[-][%s]*[@|]")
|
||||||
|
(#set! injection.language "luadoc")
|
||||||
|
(#offset! @injection.content 0 1 0 0))
|
||||||
|
|
||||||
|
; string.match("123", "%d+")
|
||||||
|
(function_call
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @_method
|
||||||
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: (string_content) @injection.content
|
||||||
|
(#set! injection.language "luap")
|
||||||
|
(#set! injection.include-children))))
|
||||||
|
|
||||||
|
;("123"):match("%d+")
|
||||||
|
(function_call
|
||||||
|
(method_index_expression
|
||||||
|
method: (identifier) @_method
|
||||||
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
content: (string_content) @injection.content
|
||||||
|
(#set! injection.language "luap")
|
||||||
|
(#set! injection.include-children))))
|
||||||
|
|
||||||
|
; string.format("pi = %.2f", 3.14159)
|
||||||
|
((function_call
|
||||||
|
(dot_index_expression
|
||||||
|
field: (identifier) @_method)
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content)))
|
||||||
|
(#eq? @_method "format")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
; ("pi = %.2f"):format(3.14159)
|
||||||
|
((function_call
|
||||||
|
(method_index_expression
|
||||||
|
table: (_
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content))
|
||||||
|
method: (identifier) @_method))
|
||||||
|
(#eq? @_method "format")
|
||||||
|
(#set! injection.language "printf"))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
content: (_) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; vim.filetype.add({ pattern = { ["some lua pattern here"] = "filetype" } })
|
||||||
|
((function_call
|
||||||
|
name: (_) @_filetypeadd_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
(table_constructor
|
||||||
|
(field
|
||||||
|
name: (_) @_pattern_key
|
||||||
|
value: (table_constructor
|
||||||
|
(field
|
||||||
|
name: (string
|
||||||
|
content: _ @injection.content)))))))
|
||||||
|
(#set! injection.language "luap")
|
||||||
|
(#eq? @_filetypeadd_identifier "vim.filetype.add")
|
||||||
|
(#eq? @_pattern_key "pattern"))
|
||||||
54
config/nvim/queries/lua/locals.scm
Normal file
54
config/nvim/queries/lua/locals.scm
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
; Scopes
|
||||||
|
[
|
||||||
|
(chunk)
|
||||||
|
(do_statement)
|
||||||
|
(while_statement)
|
||||||
|
(repeat_statement)
|
||||||
|
(if_statement)
|
||||||
|
(for_statement)
|
||||||
|
(function_declaration)
|
||||||
|
(function_definition)
|
||||||
|
] @local.scope
|
||||||
|
|
||||||
|
; Definitions
|
||||||
|
(assignment_statement
|
||||||
|
(variable_list
|
||||||
|
(identifier) @local.definition.var))
|
||||||
|
|
||||||
|
(assignment_statement
|
||||||
|
(variable_list
|
||||||
|
(dot_index_expression
|
||||||
|
.
|
||||||
|
(_) @local.definition.associated
|
||||||
|
(identifier) @local.definition.var)))
|
||||||
|
|
||||||
|
((function_declaration
|
||||||
|
name: (identifier) @local.definition.function)
|
||||||
|
(#set! definition.function.scope "parent"))
|
||||||
|
|
||||||
|
((function_declaration
|
||||||
|
name: (dot_index_expression
|
||||||
|
.
|
||||||
|
(_) @local.definition.associated
|
||||||
|
(identifier) @local.definition.function))
|
||||||
|
(#set! definition.method.scope "parent"))
|
||||||
|
|
||||||
|
((function_declaration
|
||||||
|
name: (method_index_expression
|
||||||
|
.
|
||||||
|
(_) @local.definition.associated
|
||||||
|
(identifier) @local.definition.method))
|
||||||
|
(#set! definition.method.scope "parent"))
|
||||||
|
|
||||||
|
(for_generic_clause
|
||||||
|
(variable_list
|
||||||
|
(identifier) @local.definition.var))
|
||||||
|
|
||||||
|
(for_numeric_clause
|
||||||
|
name: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(parameters
|
||||||
|
(identifier) @local.definition.parameter)
|
||||||
|
|
||||||
|
; References
|
||||||
|
(identifier) @local.reference
|
||||||
109
config/nvim/queries/lua/textobjects.scm
Normal file
109
config/nvim/queries/lua/textobjects.scm
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
; block
|
||||||
|
(_
|
||||||
|
(block) @block.inner) @block.outer
|
||||||
|
|
||||||
|
; call
|
||||||
|
(function_call) @call.outer
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
(arguments) @call.inner
|
||||||
|
(#match? @call.inner "^[^\\(]"))
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
; class
|
||||||
|
; comment
|
||||||
|
(comment
|
||||||
|
(comment_content) @comment.inner) @comment.outer
|
||||||
|
|
||||||
|
; conditional
|
||||||
|
(if_statement
|
||||||
|
alternative: (_
|
||||||
|
(_) @conditional.inner)?) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
consequence: (block)? @conditional.inner)
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
; frame
|
||||||
|
; function
|
||||||
|
[
|
||||||
|
(function_declaration)
|
||||||
|
(function_definition)
|
||||||
|
] @function.outer
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
body: (_) @function.inner)
|
||||||
|
|
||||||
|
(function_definition
|
||||||
|
body: (_) @function.inner)
|
||||||
|
|
||||||
|
; return
|
||||||
|
(return_statement
|
||||||
|
(_)? @return.inner) @return.outer
|
||||||
|
|
||||||
|
; loop
|
||||||
|
[
|
||||||
|
(while_statement)
|
||||||
|
(for_statement)
|
||||||
|
(repeat_statement)
|
||||||
|
] @loop.outer
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
body: (_) @loop.inner)
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
body: (_) @loop.inner)
|
||||||
|
|
||||||
|
(repeat_statement
|
||||||
|
body: (_) @loop.inner)
|
||||||
|
|
||||||
|
; parameter
|
||||||
|
(arguments
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(parameters
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(table_constructor
|
||||||
|
(field) @parameter.inner @parameter.outer
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(arguments
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
; number
|
||||||
|
(number) @number.inner
|
||||||
|
|
||||||
|
(assignment_statement
|
||||||
|
(variable_list) @assignment.lhs
|
||||||
|
(expression_list) @assignment.inner @assignment.rhs) @assignment.outer
|
||||||
|
|
||||||
|
(assignment_statement
|
||||||
|
(variable_list) @assignment.inner)
|
||||||
|
|
||||||
|
; scopename
|
||||||
|
; statement
|
||||||
|
(statement) @statement.outer
|
||||||
|
|
||||||
|
(return_statement) @statement.outer
|
||||||
11
config/nvim/queries/nix/folds.scm
Normal file
11
config/nvim/queries/nix/folds.scm
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
; Nix doesn't really have blocks, so just guess what people might want folds for
|
||||||
|
[
|
||||||
|
(if_expression)
|
||||||
|
(with_expression)
|
||||||
|
(let_expression)
|
||||||
|
(function_expression)
|
||||||
|
(attrset_expression)
|
||||||
|
(rec_attrset_expression)
|
||||||
|
(list_expression)
|
||||||
|
(indented_string_expression)
|
||||||
|
] @fold
|
||||||
210
config/nvim/queries/nix/highlights.scm
Normal file
210
config/nvim/queries/nix/highlights.scm
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
; basic keywords
|
||||||
|
[
|
||||||
|
"assert"
|
||||||
|
"in"
|
||||||
|
"inherit"
|
||||||
|
"let"
|
||||||
|
"rec"
|
||||||
|
"with"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
; if/then/else
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"then"
|
||||||
|
"else"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
; field access default (`a.b or c`)
|
||||||
|
"or" @keyword.operator
|
||||||
|
|
||||||
|
; comments
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
; strings
|
||||||
|
(string_fragment) @string
|
||||||
|
|
||||||
|
(string_expression
|
||||||
|
"\"" @string)
|
||||||
|
|
||||||
|
(indented_string_expression
|
||||||
|
"''" @string)
|
||||||
|
|
||||||
|
; paths and URLs
|
||||||
|
[
|
||||||
|
(path_expression)
|
||||||
|
(hpath_expression)
|
||||||
|
(spath_expression)
|
||||||
|
] @string.special.path
|
||||||
|
|
||||||
|
(uri_expression) @string.special.url
|
||||||
|
|
||||||
|
; escape sequences
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
; delimiters
|
||||||
|
[
|
||||||
|
"."
|
||||||
|
";"
|
||||||
|
":"
|
||||||
|
","
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
; brackets
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
; `?` in `{ x ? y }:`, used to set defaults for named function arguments
|
||||||
|
(formal
|
||||||
|
name: (identifier) @variable.parameter
|
||||||
|
"?"? @operator)
|
||||||
|
|
||||||
|
; `...` in `{ ... }`, used to ignore unknown named function arguments (see above)
|
||||||
|
(ellipses) @variable.parameter.builtin
|
||||||
|
|
||||||
|
; universal is the parameter of the function expression
|
||||||
|
; `:` in `x: y`, used to separate function argument from body (see above)
|
||||||
|
(function_expression
|
||||||
|
universal: (identifier) @variable.parameter
|
||||||
|
":" @punctuation.special)
|
||||||
|
|
||||||
|
; function calls
|
||||||
|
(apply_expression
|
||||||
|
function: (variable_expression
|
||||||
|
name: (identifier) @function.call))
|
||||||
|
|
||||||
|
; basic identifiers
|
||||||
|
(variable_expression) @variable
|
||||||
|
|
||||||
|
(variable_expression
|
||||||
|
name: (identifier) @keyword.import
|
||||||
|
(#eq? @keyword.import "import"))
|
||||||
|
|
||||||
|
(variable_expression
|
||||||
|
name: (identifier) @boolean
|
||||||
|
(#any-of? @boolean "true" "false"))
|
||||||
|
|
||||||
|
; string interpolation (this was very annoying to get working properly)
|
||||||
|
(interpolation
|
||||||
|
"${" @punctuation.special
|
||||||
|
(_)
|
||||||
|
"}" @punctuation.special) @none
|
||||||
|
|
||||||
|
(select_expression
|
||||||
|
expression: (_) @_expr
|
||||||
|
attrpath: (attrpath
|
||||||
|
attr: (identifier) @variable.member)
|
||||||
|
(#not-eq? @_expr "builtins"))
|
||||||
|
|
||||||
|
(attrset_expression
|
||||||
|
(binding_set
|
||||||
|
(binding
|
||||||
|
.
|
||||||
|
(attrpath
|
||||||
|
(identifier) @variable.member))))
|
||||||
|
|
||||||
|
(rec_attrset_expression
|
||||||
|
(binding_set
|
||||||
|
(binding
|
||||||
|
.
|
||||||
|
(attrpath
|
||||||
|
(identifier) @variable.member))))
|
||||||
|
|
||||||
|
function: (select_expression
|
||||||
|
attrpath: (attrpath
|
||||||
|
attr: (identifier) @function.call .))
|
||||||
|
|
||||||
|
; builtin functions (with builtins prefix)
|
||||||
|
(select_expression
|
||||||
|
expression: (variable_expression
|
||||||
|
name: (identifier) @_id)
|
||||||
|
attrpath: (attrpath
|
||||||
|
attr: (identifier) @function.builtin)
|
||||||
|
(#eq? @_id "builtins"))
|
||||||
|
|
||||||
|
; builtin functions (without builtins prefix)
|
||||||
|
(variable_expression
|
||||||
|
name: (identifier) @function.builtin
|
||||||
|
(#any-of? @function.builtin
|
||||||
|
; nix eval --impure --expr 'with builtins; filter (x: !(elem x [ "abort" "import" "throw" ]) && isFunction builtins.${x}) (attrNames builtins)'
|
||||||
|
"add" "addErrorContext" "all" "any" "appendContext" "attrNames" "attrValues" "baseNameOf"
|
||||||
|
"bitAnd" "bitOr" "bitXor" "break" "catAttrs" "ceil" "compareVersions" "concatLists" "concatMap"
|
||||||
|
"concatStringsSep" "deepSeq" "derivation" "derivationStrict" "dirOf" "div" "elem" "elemAt"
|
||||||
|
"fetchGit" "fetchMercurial" "fetchTarball" "fetchTree" "fetchurl" "filter" "filterSource"
|
||||||
|
"findFile" "floor" "foldl'" "fromJSON" "fromTOML" "functionArgs" "genList" "genericClosure"
|
||||||
|
"getAttr" "getContext" "getEnv" "getFlake" "groupBy" "hasAttr" "hasContext" "hashFile"
|
||||||
|
"hashString" "head" "intersectAttrs" "isAttrs" "isBool" "isFloat" "isFunction" "isInt" "isList"
|
||||||
|
"isNull" "isPath" "isString" "length" "lessThan" "listToAttrs" "map" "mapAttrs" "match" "mul"
|
||||||
|
"parseDrvName" "partition" "path" "pathExists" "placeholder" "readDir" "readFile" "removeAttrs"
|
||||||
|
"replaceStrings" "scopedImport" "seq" "sort" "split" "splitVersion" "storePath" "stringLength"
|
||||||
|
"sub" "substring" "tail" "toFile" "toJSON" "toPath" "toString" "toXML" "trace" "traceVerbose"
|
||||||
|
"tryEval" "typeOf" "unsafeDiscardOutputDependency" "unsafeDiscardStringContext"
|
||||||
|
"unsafeGetAttrPos" "zipAttrsWith"
|
||||||
|
; primops, `__<tab>` in `nix repl`
|
||||||
|
"__add" "__filter" "__isFunction" "__split" "__addErrorContext" "__filterSource" "__isInt"
|
||||||
|
"__splitVersion" "__all" "__findFile" "__isList" "__storeDir" "__any" "__floor" "__isPath"
|
||||||
|
"__storePath" "__appendContext" "__foldl'" "__isString" "__stringLength" "__attrNames"
|
||||||
|
"__fromJSON" "__langVersion" "__sub" "__attrValues" "__functionArgs" "__length" "__substring"
|
||||||
|
"__bitAnd" "__genList" "__lessThan" "__tail" "__bitOr" "__genericClosure" "__listToAttrs"
|
||||||
|
"__toFile" "__bitXor" "__getAttr" "__mapAttrs" "__toJSON" "__catAttrs" "__getContext" "__match"
|
||||||
|
"__toPath" "__ceil" "__getEnv" "__mul" "__toXML" "__compareVersions" "__getFlake" "__nixPath"
|
||||||
|
"__trace" "__concatLists" "__groupBy" "__nixVersion" "__traceVerbose" "__concatMap" "__hasAttr"
|
||||||
|
"__parseDrvName" "__tryEval" "__concatStringsSep" "__hasContext" "__partition" "__typeOf"
|
||||||
|
"__currentSystem" "__hashFile" "__path" "__unsafeDiscardOutputDependency" "__currentTime"
|
||||||
|
"__hashString" "__pathExists" "__unsafeDiscardStringContext" "__deepSeq" "__head" "__readDir"
|
||||||
|
"__unsafeGetAttrPos" "__div" "__intersectAttrs" "__readFile" "__zipAttrsWith" "__elem"
|
||||||
|
"__isAttrs" "__replaceStrings" "__elemAt" "__isBool" "__seq" "__fetchurl" "__isFloat" "__sort"))
|
||||||
|
|
||||||
|
; constants
|
||||||
|
(variable_expression
|
||||||
|
name: (identifier) @constant.builtin
|
||||||
|
(#any-of? @constant.builtin
|
||||||
|
; nix eval --impure --expr 'with builtins; filter (x: !(isFunction builtins.${x} || isBool builtins.${x})) (attrNames builtins)'
|
||||||
|
"builtins" "currentSystem" "currentTime" "langVersion" "nixPath" "nixVersion" "null" "storeDir"))
|
||||||
|
|
||||||
|
; function definition
|
||||||
|
(binding
|
||||||
|
attrpath: (attrpath
|
||||||
|
attr: (identifier) @function)
|
||||||
|
expression: (function_expression))
|
||||||
|
|
||||||
|
; unary operators
|
||||||
|
(unary_expression
|
||||||
|
operator: _ @operator)
|
||||||
|
|
||||||
|
; binary operators
|
||||||
|
(binary_expression
|
||||||
|
operator: _ @operator)
|
||||||
|
|
||||||
|
[
|
||||||
|
"="
|
||||||
|
"@"
|
||||||
|
"?"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; integers, also highlight a unary -
|
||||||
|
[
|
||||||
|
(unary_expression
|
||||||
|
"-"
|
||||||
|
(integer_expression))
|
||||||
|
(integer_expression)
|
||||||
|
] @number
|
||||||
|
|
||||||
|
; floats, also highlight a unary -
|
||||||
|
[
|
||||||
|
(unary_expression
|
||||||
|
"-"
|
||||||
|
(float_expression))
|
||||||
|
(float_expression)
|
||||||
|
] @number.float
|
||||||
|
|
||||||
|
; exceptions
|
||||||
|
(variable_expression
|
||||||
|
name: (identifier) @keyword.exception
|
||||||
|
(#any-of? @keyword.exception "abort" "throw"))
|
||||||
190
config/nvim/queries/nix/injections.scm
Normal file
190
config/nvim/queries/nix/injections.scm
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
((comment) @injection.language
|
||||||
|
. ; this is to make sure only adjacent comments are accounted for the injections
|
||||||
|
[
|
||||||
|
(string_expression
|
||||||
|
(string_fragment) @injection.content)
|
||||||
|
(indented_string_expression
|
||||||
|
(string_fragment) @injection.content)
|
||||||
|
]
|
||||||
|
(#gsub! @injection.language "/%*%s*([%w%p]+)%s*%*/" "%1")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
; #-style Comments
|
||||||
|
((comment) @injection.language
|
||||||
|
. ; this is to make sure only adjacent comments are accounted for the injections
|
||||||
|
[
|
||||||
|
(string_expression
|
||||||
|
(string_fragment) @injection.content)
|
||||||
|
(indented_string_expression
|
||||||
|
(string_fragment) @injection.content)
|
||||||
|
]
|
||||||
|
(#gsub! @injection.language "#%s*([%w%p]+)%s*" "%1")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
(apply_expression
|
||||||
|
function: (_) @_func
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "regex")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "regex")))
|
||||||
|
]
|
||||||
|
(#match? @_func "(^|\\.)match$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
(binding
|
||||||
|
attrpath: (attrpath
|
||||||
|
(identifier) @_path)
|
||||||
|
expression: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
]
|
||||||
|
(#match? @_path "(^\\w+(Phase|Hook|Check)|(pre|post)[A-Z]\\w+|script)$"))
|
||||||
|
|
||||||
|
(apply_expression
|
||||||
|
function: (_) @_func
|
||||||
|
argument: (_
|
||||||
|
(_)*
|
||||||
|
(_
|
||||||
|
(_)*
|
||||||
|
(binding
|
||||||
|
attrpath: (attrpath
|
||||||
|
(identifier) @_path)
|
||||||
|
expression: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
])))
|
||||||
|
(#match? @_func "(^|\\.)writeShellApplication$")
|
||||||
|
(#match? @_path "^text$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
(apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func))
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
]
|
||||||
|
(#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func)
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "bash")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func)
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "fish")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "fish")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)writeFish(Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func))
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "haskell")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "haskell")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)writeHaskell(Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func))
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "javascript")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "javascript")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)writeJS(Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func))
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "perl")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "perl")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)writePerl(Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func))
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "python")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "python")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (apply_expression
|
||||||
|
function: (_) @_func))
|
||||||
|
argument: [
|
||||||
|
(string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "rust")))
|
||||||
|
(indented_string_expression
|
||||||
|
((string_fragment) @injection.content
|
||||||
|
(#set! injection.language "rust")))
|
||||||
|
])
|
||||||
|
(#match? @_func "(^|\\.)writeRust(Bin)?$")
|
||||||
|
(#set! injection.combined))
|
||||||
34
config/nvim/queries/nix/locals.scm
Normal file
34
config/nvim/queries/nix/locals.scm
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
; let bindings
|
||||||
|
(let_expression
|
||||||
|
(binding_set
|
||||||
|
(binding
|
||||||
|
.
|
||||||
|
(attrpath) @local.definition.var))) @local.scope
|
||||||
|
|
||||||
|
; rec attrsets
|
||||||
|
(rec_attrset_expression
|
||||||
|
(binding_set
|
||||||
|
(binding
|
||||||
|
.
|
||||||
|
(attrpath) @local.definition.field))) @local.scope
|
||||||
|
|
||||||
|
; functions and parameters
|
||||||
|
(function_expression
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(identifier) @local.definition.parameter
|
||||||
|
(formals
|
||||||
|
(formal
|
||||||
|
.
|
||||||
|
(identifier) @local.definition.parameter))
|
||||||
|
]) @local.scope
|
||||||
|
|
||||||
|
((formals)
|
||||||
|
"@"
|
||||||
|
(identifier) @local.definition.parameter) ; I couldn't get this to work properly inside the (function)
|
||||||
|
|
||||||
|
(variable_expression
|
||||||
|
(identifier) @local.reference)
|
||||||
|
|
||||||
|
(inherited_attrs
|
||||||
|
attr: (identifier) @local.reference)
|
||||||
26
config/nvim/queries/nix/textobjects.scm
Normal file
26
config/nvim/queries/nix/textobjects.scm
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
; named function
|
||||||
|
(binding
|
||||||
|
(function_expression)) @function.outer
|
||||||
|
|
||||||
|
; anonymous function
|
||||||
|
(function_expression
|
||||||
|
(_) ; argument
|
||||||
|
(_) @function.inner) @function.outer
|
||||||
|
|
||||||
|
(function_expression
|
||||||
|
(formals
|
||||||
|
(formal) @parameter.inner))
|
||||||
|
|
||||||
|
(function_expression
|
||||||
|
(_) @parameter.outer
|
||||||
|
(_))
|
||||||
|
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
(if_expression
|
||||||
|
(_) @conditional.inner) @conditional.outer
|
||||||
|
|
||||||
|
[
|
||||||
|
(integer_expression)
|
||||||
|
(float_expression)
|
||||||
|
] @number.inner
|
||||||
1
config/nvim/queries/php/folds.scm
Normal file
1
config/nvim/queries/php/folds.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits: php_only
|
||||||
1
config/nvim/queries/php/highlights.scm
Normal file
1
config/nvim/queries/php/highlights.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits: php_only
|
||||||
5
config/nvim/queries/php/injections.scm
Normal file
5
config/nvim/queries/php/injections.scm
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
; inherits: php_only
|
||||||
|
|
||||||
|
((text) @injection.content
|
||||||
|
(#set! injection.language "html")
|
||||||
|
(#set! injection.combined))
|
||||||
1
config/nvim/queries/php/locals.scm
Normal file
1
config/nvim/queries/php/locals.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits: php_only
|
||||||
235
config/nvim/queries/php/textobjects.scm
Normal file
235
config/nvim/queries/php/textobjects.scm
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
; functions
|
||||||
|
(function_definition
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(function_definition) @function.outer
|
||||||
|
|
||||||
|
(anonymous_function
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(anonymous_function) @function.outer
|
||||||
|
|
||||||
|
; methods
|
||||||
|
(method_declaration
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(method_declaration) @function.outer
|
||||||
|
|
||||||
|
; traits
|
||||||
|
(trait_declaration
|
||||||
|
body: (declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(trait_declaration) @class.outer
|
||||||
|
|
||||||
|
; interfaces
|
||||||
|
(interface_declaration
|
||||||
|
body: (declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(interface_declaration) @class.outer
|
||||||
|
|
||||||
|
; enums
|
||||||
|
(enum_declaration
|
||||||
|
body: (enum_declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(enum_declaration) @class.outer
|
||||||
|
|
||||||
|
; classes
|
||||||
|
(class_declaration
|
||||||
|
body: (declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(class_declaration) @class.outer
|
||||||
|
|
||||||
|
; loops
|
||||||
|
(for_statement
|
||||||
|
(compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(for_statement) @loop.outer
|
||||||
|
|
||||||
|
(foreach_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(foreach_statement) @loop.outer
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(while_statement) @loop.outer
|
||||||
|
|
||||||
|
(do_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(do_statement) @loop.outer
|
||||||
|
|
||||||
|
; conditionals
|
||||||
|
(switch_statement
|
||||||
|
body: (switch_block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(switch_statement) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(if_statement) @conditional.outer
|
||||||
|
|
||||||
|
(else_clause
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(else_if_clause
|
||||||
|
body: (compound_statement
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; blocks
|
||||||
|
(_
|
||||||
|
(switch_block) @block.inner) @block.outer
|
||||||
|
|
||||||
|
; parameters
|
||||||
|
(arguments
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(arguments
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(formal_parameters
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; comments
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
; call
|
||||||
|
(function_call_expression) @call.outer
|
||||||
|
|
||||||
|
(member_call_expression) @call.outer
|
||||||
|
|
||||||
|
(nullsafe_member_call_expression) @call.outer
|
||||||
|
|
||||||
|
(scoped_call_expression) @call.outer
|
||||||
|
|
||||||
|
(function_call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(member_call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(nullsafe_member_call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(scoped_call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
; statement
|
||||||
|
[
|
||||||
|
(expression_statement)
|
||||||
|
(declare_statement)
|
||||||
|
(return_statement)
|
||||||
|
(namespace_use_declaration)
|
||||||
|
(namespace_definition)
|
||||||
|
(if_statement)
|
||||||
|
(empty_statement)
|
||||||
|
(switch_statement)
|
||||||
|
(while_statement)
|
||||||
|
(do_statement)
|
||||||
|
(for_statement)
|
||||||
|
(foreach_statement)
|
||||||
|
(goto_statement)
|
||||||
|
(continue_statement)
|
||||||
|
(break_statement)
|
||||||
|
(try_statement)
|
||||||
|
(echo_statement)
|
||||||
|
(unset_statement)
|
||||||
|
(const_declaration)
|
||||||
|
(function_definition)
|
||||||
|
(class_declaration)
|
||||||
|
(interface_declaration)
|
||||||
|
(trait_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(global_declaration)
|
||||||
|
(function_static_declaration)
|
||||||
|
] @statement.outer
|
||||||
17
config/nvim/queries/php_only/folds.scm
Normal file
17
config/nvim/queries/php_only/folds.scm
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
(if_statement)
|
||||||
|
(switch_statement)
|
||||||
|
(while_statement)
|
||||||
|
(do_statement)
|
||||||
|
(for_statement)
|
||||||
|
(foreach_statement)
|
||||||
|
(try_statement)
|
||||||
|
(function_definition)
|
||||||
|
(class_declaration)
|
||||||
|
(interface_declaration)
|
||||||
|
(trait_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(function_static_declaration)
|
||||||
|
(method_declaration)
|
||||||
|
(namespace_use_declaration)+
|
||||||
|
] @fold
|
||||||
479
config/nvim/queries/php_only/highlights.scm
Normal file
479
config/nvim/queries/php_only/highlights.scm
Normal file
@@ -0,0 +1,479 @@
|
|||||||
|
; Keywords
|
||||||
|
[
|
||||||
|
"and"
|
||||||
|
"as"
|
||||||
|
"instanceof"
|
||||||
|
"or"
|
||||||
|
"xor"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"fn"
|
||||||
|
"function"
|
||||||
|
] @keyword.function
|
||||||
|
|
||||||
|
[
|
||||||
|
"clone"
|
||||||
|
"declare"
|
||||||
|
"default"
|
||||||
|
"echo"
|
||||||
|
"enddeclare"
|
||||||
|
"extends"
|
||||||
|
"global"
|
||||||
|
"goto"
|
||||||
|
"implements"
|
||||||
|
"insteadof"
|
||||||
|
"print"
|
||||||
|
"new"
|
||||||
|
"unset"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"enum"
|
||||||
|
"class"
|
||||||
|
"interface"
|
||||||
|
"namespace"
|
||||||
|
"trait"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
[
|
||||||
|
"abstract"
|
||||||
|
"const"
|
||||||
|
"final"
|
||||||
|
"private"
|
||||||
|
"protected"
|
||||||
|
"public"
|
||||||
|
"readonly"
|
||||||
|
(static_modifier)
|
||||||
|
] @keyword.modifier
|
||||||
|
|
||||||
|
(function_static_declaration
|
||||||
|
"static" @keyword.modifier)
|
||||||
|
|
||||||
|
[
|
||||||
|
"return"
|
||||||
|
"exit"
|
||||||
|
"yield"
|
||||||
|
] @keyword.return
|
||||||
|
|
||||||
|
(yield_expression
|
||||||
|
"from" @keyword.return)
|
||||||
|
|
||||||
|
[
|
||||||
|
"case"
|
||||||
|
"else"
|
||||||
|
"elseif"
|
||||||
|
"endif"
|
||||||
|
"endswitch"
|
||||||
|
"if"
|
||||||
|
"switch"
|
||||||
|
"match"
|
||||||
|
"??"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
"do"
|
||||||
|
"endfor"
|
||||||
|
"endforeach"
|
||||||
|
"endwhile"
|
||||||
|
"for"
|
||||||
|
"foreach"
|
||||||
|
"while"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"catch"
|
||||||
|
"finally"
|
||||||
|
"throw"
|
||||||
|
"try"
|
||||||
|
] @keyword.exception
|
||||||
|
|
||||||
|
[
|
||||||
|
"include_once"
|
||||||
|
"include"
|
||||||
|
"require_once"
|
||||||
|
"require"
|
||||||
|
"use"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
";"
|
||||||
|
":"
|
||||||
|
"\\"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
(php_tag)
|
||||||
|
"?>"
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
"#["
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
"="
|
||||||
|
"."
|
||||||
|
"-"
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"+"
|
||||||
|
"%"
|
||||||
|
"**"
|
||||||
|
"~"
|
||||||
|
"|"
|
||||||
|
"^"
|
||||||
|
"&"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"<<<"
|
||||||
|
"->"
|
||||||
|
"?->"
|
||||||
|
"=>"
|
||||||
|
"<"
|
||||||
|
"<="
|
||||||
|
">="
|
||||||
|
">"
|
||||||
|
"<>"
|
||||||
|
"<=>"
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
"==="
|
||||||
|
"!=="
|
||||||
|
"!"
|
||||||
|
"&&"
|
||||||
|
"||"
|
||||||
|
".="
|
||||||
|
"-="
|
||||||
|
"+="
|
||||||
|
"*="
|
||||||
|
"/="
|
||||||
|
"%="
|
||||||
|
"**="
|
||||||
|
"&="
|
||||||
|
"|="
|
||||||
|
"^="
|
||||||
|
"<<="
|
||||||
|
">>="
|
||||||
|
"??="
|
||||||
|
"--"
|
||||||
|
"++"
|
||||||
|
"@"
|
||||||
|
"::"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Variables
|
||||||
|
(variable_name) @variable
|
||||||
|
|
||||||
|
; Constants
|
||||||
|
((name) @constant
|
||||||
|
(#lua-match? @constant "^_?[A-Z][A-Z%d_]*$"))
|
||||||
|
|
||||||
|
((name) @constant.builtin
|
||||||
|
(#lua-match? @constant.builtin "^__[A-Z][A-Z%d_]+__$"))
|
||||||
|
|
||||||
|
(const_declaration
|
||||||
|
(const_element
|
||||||
|
(name) @constant))
|
||||||
|
|
||||||
|
; Types
|
||||||
|
[
|
||||||
|
(primitive_type)
|
||||||
|
(cast_type)
|
||||||
|
(bottom_type)
|
||||||
|
] @type.builtin
|
||||||
|
|
||||||
|
(named_type
|
||||||
|
[
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
])
|
||||||
|
|
||||||
|
(named_type
|
||||||
|
(name) @type.builtin
|
||||||
|
(#any-of? @type.builtin "static" "self"))
|
||||||
|
|
||||||
|
(class_declaration
|
||||||
|
name: (name) @type)
|
||||||
|
|
||||||
|
(base_clause
|
||||||
|
[
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
])
|
||||||
|
|
||||||
|
(enum_declaration
|
||||||
|
name: (name) @type)
|
||||||
|
|
||||||
|
(interface_declaration
|
||||||
|
name: (name) @type)
|
||||||
|
|
||||||
|
(namespace_use_clause
|
||||||
|
[
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
alias: (name) @type.definition
|
||||||
|
])
|
||||||
|
|
||||||
|
(namespace_use_clause
|
||||||
|
type: "function"
|
||||||
|
[
|
||||||
|
(name) @function
|
||||||
|
(qualified_name
|
||||||
|
(name) @function)
|
||||||
|
alias: (name) @function
|
||||||
|
])
|
||||||
|
|
||||||
|
(namespace_use_declaration
|
||||||
|
type: "function"
|
||||||
|
body: (namespace_use_group
|
||||||
|
(namespace_use_clause
|
||||||
|
[
|
||||||
|
(name) @function
|
||||||
|
(qualified_name
|
||||||
|
(name) @function)
|
||||||
|
alias: (name) @function
|
||||||
|
])))
|
||||||
|
|
||||||
|
(namespace_use_clause
|
||||||
|
type: "const"
|
||||||
|
[
|
||||||
|
(name) @constant
|
||||||
|
(qualified_name
|
||||||
|
(name) @constant)
|
||||||
|
alias: (name) @constant
|
||||||
|
])
|
||||||
|
|
||||||
|
(namespace_use_declaration
|
||||||
|
type: "const"
|
||||||
|
body: (namespace_use_group
|
||||||
|
(namespace_use_clause
|
||||||
|
[
|
||||||
|
(name) @constant
|
||||||
|
(qualified_name
|
||||||
|
(name) @constant)
|
||||||
|
alias: (name) @constant
|
||||||
|
])))
|
||||||
|
|
||||||
|
(class_interface_clause
|
||||||
|
[
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
])
|
||||||
|
|
||||||
|
(scoped_call_expression
|
||||||
|
scope: [
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
])
|
||||||
|
|
||||||
|
(class_constant_access_expression
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
]
|
||||||
|
(name) @constant)
|
||||||
|
|
||||||
|
(scoped_property_access_expression
|
||||||
|
scope: [
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
])
|
||||||
|
|
||||||
|
(scoped_property_access_expression
|
||||||
|
name: (variable_name) @variable.member)
|
||||||
|
|
||||||
|
(trait_declaration
|
||||||
|
name: (name) @type)
|
||||||
|
|
||||||
|
(use_declaration
|
||||||
|
(name) @type)
|
||||||
|
|
||||||
|
(binary_expression
|
||||||
|
operator: "instanceof"
|
||||||
|
right: [
|
||||||
|
(name) @type
|
||||||
|
(qualified_name
|
||||||
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
|
])
|
||||||
|
|
||||||
|
; Functions, methods, constructors
|
||||||
|
(array_creation_expression
|
||||||
|
"array" @function.builtin)
|
||||||
|
|
||||||
|
(list_literal
|
||||||
|
"list" @function.builtin)
|
||||||
|
|
||||||
|
(exit_statement
|
||||||
|
"exit" @function.builtin
|
||||||
|
"(")
|
||||||
|
|
||||||
|
(method_declaration
|
||||||
|
name: (name) @function.method)
|
||||||
|
|
||||||
|
(function_call_expression
|
||||||
|
function: [
|
||||||
|
(name) @function.call
|
||||||
|
(qualified_name
|
||||||
|
(name) @function.call)
|
||||||
|
(relative_name
|
||||||
|
(name) @function.call)
|
||||||
|
])
|
||||||
|
|
||||||
|
(scoped_call_expression
|
||||||
|
name: (name) @function.call)
|
||||||
|
|
||||||
|
(member_call_expression
|
||||||
|
name: (name) @function.method.call)
|
||||||
|
|
||||||
|
(function_definition
|
||||||
|
name: (name) @function)
|
||||||
|
|
||||||
|
(nullsafe_member_call_expression
|
||||||
|
name: (name) @function.method)
|
||||||
|
|
||||||
|
(use_instead_of_clause
|
||||||
|
(class_constant_access_expression
|
||||||
|
(_)
|
||||||
|
(name) @function.method)
|
||||||
|
(name) @type)
|
||||||
|
|
||||||
|
(use_as_clause
|
||||||
|
(class_constant_access_expression
|
||||||
|
(_)
|
||||||
|
(name) @function.method)*
|
||||||
|
(name) @function.method)
|
||||||
|
|
||||||
|
(method_declaration
|
||||||
|
name: (name) @constructor
|
||||||
|
(#eq? @constructor "__construct"))
|
||||||
|
|
||||||
|
(object_creation_expression
|
||||||
|
[
|
||||||
|
(name) @constructor
|
||||||
|
(qualified_name
|
||||||
|
(name) @constructor)
|
||||||
|
(relative_name
|
||||||
|
(name) @constructor)
|
||||||
|
])
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
(variadic_parameter
|
||||||
|
"..." @operator
|
||||||
|
name: (variable_name) @variable.parameter)
|
||||||
|
|
||||||
|
(simple_parameter
|
||||||
|
name: (variable_name) @variable.parameter)
|
||||||
|
|
||||||
|
(argument
|
||||||
|
(name) @variable.parameter)
|
||||||
|
|
||||||
|
; Member
|
||||||
|
(property_element
|
||||||
|
(variable_name) @property)
|
||||||
|
|
||||||
|
(member_access_expression
|
||||||
|
name: (variable_name
|
||||||
|
(name)) @variable.member)
|
||||||
|
|
||||||
|
(member_access_expression
|
||||||
|
name: (name) @variable.member)
|
||||||
|
|
||||||
|
(nullsafe_member_access_expression
|
||||||
|
name: (variable_name
|
||||||
|
(name)) @variable.member)
|
||||||
|
|
||||||
|
(nullsafe_member_access_expression
|
||||||
|
name: (name) @variable.member)
|
||||||
|
|
||||||
|
; Variables
|
||||||
|
(relative_scope) @variable.builtin
|
||||||
|
|
||||||
|
((variable_name) @variable.builtin
|
||||||
|
(#eq? @variable.builtin "$this"))
|
||||||
|
|
||||||
|
; Namespace
|
||||||
|
(namespace_definition
|
||||||
|
name: (namespace_name
|
||||||
|
(name) @module))
|
||||||
|
|
||||||
|
(namespace_name
|
||||||
|
(name) @module)
|
||||||
|
|
||||||
|
(relative_name
|
||||||
|
"namespace" @module.builtin)
|
||||||
|
|
||||||
|
; Attributes
|
||||||
|
(attribute_list) @attribute
|
||||||
|
|
||||||
|
; Conditions ( ? : )
|
||||||
|
(conditional_expression
|
||||||
|
"?" @keyword.conditional.ternary
|
||||||
|
":" @keyword.conditional.ternary)
|
||||||
|
|
||||||
|
; Directives
|
||||||
|
(declare_directive
|
||||||
|
[
|
||||||
|
"strict_types"
|
||||||
|
"ticks"
|
||||||
|
"encoding"
|
||||||
|
] @variable.parameter)
|
||||||
|
|
||||||
|
; Basic tokens
|
||||||
|
[
|
||||||
|
(string)
|
||||||
|
(encapsed_string)
|
||||||
|
(heredoc_body)
|
||||||
|
(nowdoc_body)
|
||||||
|
(shell_command_expression) ; backtick operator: `ls -la`
|
||||||
|
] @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
[
|
||||||
|
(heredoc_start)
|
||||||
|
(heredoc_end)
|
||||||
|
] @label
|
||||||
|
|
||||||
|
(nowdoc
|
||||||
|
"'" @label)
|
||||||
|
|
||||||
|
(boolean) @boolean
|
||||||
|
|
||||||
|
(null) @constant.builtin
|
||||||
|
|
||||||
|
(integer) @number
|
||||||
|
|
||||||
|
(float) @number.float
|
||||||
|
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
(named_label_statement) @label
|
||||||
43
config/nvim/queries/php_only/injections.scm
Normal file
43
config/nvim/queries/php_only/injections.scm
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "phpdoc"))
|
||||||
|
|
||||||
|
(heredoc
|
||||||
|
(heredoc_body) @injection.content
|
||||||
|
(heredoc_end) @injection.language
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#downcase! @injection.language))
|
||||||
|
|
||||||
|
(nowdoc
|
||||||
|
(nowdoc_body) @injection.content
|
||||||
|
(heredoc_end) @injection.language
|
||||||
|
(#set! injection.include-children)
|
||||||
|
(#downcase! @injection.language))
|
||||||
|
|
||||||
|
; regex
|
||||||
|
((function_call_expression
|
||||||
|
function: (_) @_preg_func_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(argument
|
||||||
|
(_
|
||||||
|
(string_content) @injection.content))))
|
||||||
|
(#set! injection.language "regex")
|
||||||
|
(#lua-match? @_preg_func_identifier "^preg_"))
|
||||||
|
|
||||||
|
; bash
|
||||||
|
((function_call_expression
|
||||||
|
function: (_) @_shell_func_identifier
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
(argument
|
||||||
|
(_
|
||||||
|
(string_content) @injection.content))))
|
||||||
|
(#set! injection.language "bash")
|
||||||
|
(#any-of? @_shell_func_identifier
|
||||||
|
"shell_exec" "escapeshellarg" "escapeshellcmd" "exec" "passthru" "proc_open" "shell_exec"
|
||||||
|
"system"))
|
||||||
|
|
||||||
|
(expression_statement
|
||||||
|
(shell_command_expression
|
||||||
|
(string_content) @injection.content)
|
||||||
|
(#set! injection.language "bash"))
|
||||||
84
config/nvim/queries/php_only/locals.scm
Normal file
84
config/nvim/queries/php_only/locals.scm
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
; Scopes
|
||||||
|
;-------
|
||||||
|
((class_declaration
|
||||||
|
name: (name) @local.definition.type) @local.scope
|
||||||
|
(#set! definition.type.scope "parent"))
|
||||||
|
|
||||||
|
((method_declaration
|
||||||
|
name: (name) @local.definition.method) @local.scope
|
||||||
|
(#set! definition.method.scope "parent"))
|
||||||
|
|
||||||
|
((function_definition
|
||||||
|
name: (name) @local.definition.function) @local.scope
|
||||||
|
(#set! definition.function.scope "parent"))
|
||||||
|
|
||||||
|
(anonymous_function
|
||||||
|
(anonymous_function_use_clause
|
||||||
|
(variable_name
|
||||||
|
(name) @local.definition.var))) @local.scope
|
||||||
|
|
||||||
|
; Definitions
|
||||||
|
;------------
|
||||||
|
(simple_parameter
|
||||||
|
(variable_name
|
||||||
|
(name) @local.definition.var))
|
||||||
|
|
||||||
|
(foreach_statement
|
||||||
|
(pair
|
||||||
|
(variable_name
|
||||||
|
(name) @local.definition.var)))
|
||||||
|
|
||||||
|
(foreach_statement
|
||||||
|
(variable_name
|
||||||
|
(name) @local.reference
|
||||||
|
(#set! reference.kind "var"))
|
||||||
|
(variable_name
|
||||||
|
(name) @local.definition.var))
|
||||||
|
|
||||||
|
(property_declaration
|
||||||
|
(property_element
|
||||||
|
(variable_name
|
||||||
|
(name) @local.definition.field)))
|
||||||
|
|
||||||
|
(namespace_use_clause
|
||||||
|
(qualified_name
|
||||||
|
(name) @local.definition.type))
|
||||||
|
|
||||||
|
; References
|
||||||
|
;------------
|
||||||
|
(named_type
|
||||||
|
(name) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(named_type
|
||||||
|
(qualified_name) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(variable_name
|
||||||
|
(name) @local.reference
|
||||||
|
(#set! reference.kind "var"))
|
||||||
|
|
||||||
|
(member_access_expression
|
||||||
|
name: (name) @local.reference
|
||||||
|
(#set! reference.kind "field"))
|
||||||
|
|
||||||
|
(member_call_expression
|
||||||
|
name: (name) @local.reference
|
||||||
|
(#set! reference.kind "method"))
|
||||||
|
|
||||||
|
(function_call_expression
|
||||||
|
function: (qualified_name
|
||||||
|
(name) @local.reference
|
||||||
|
(#set! reference.kind "function")))
|
||||||
|
|
||||||
|
(object_creation_expression
|
||||||
|
(qualified_name
|
||||||
|
(name) @local.reference
|
||||||
|
(#set! reference.kind "type")))
|
||||||
|
|
||||||
|
(scoped_call_expression
|
||||||
|
scope: (qualified_name
|
||||||
|
(name) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
name: (name) @local.reference
|
||||||
|
(#set! reference.kind "method"))
|
||||||
1
config/nvim/queries/php_only/textobjects.scm
Normal file
1
config/nvim/queries/php_only/textobjects.scm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
; inherits php
|
||||||
25
config/nvim/queries/rust/folds.scm
Normal file
25
config/nvim/queries/rust/folds.scm
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[
|
||||||
|
(mod_item)
|
||||||
|
(foreign_mod_item)
|
||||||
|
(function_item)
|
||||||
|
(struct_item)
|
||||||
|
(trait_item)
|
||||||
|
(enum_item)
|
||||||
|
(impl_item)
|
||||||
|
(type_item)
|
||||||
|
(union_item)
|
||||||
|
(const_item)
|
||||||
|
(let_declaration)
|
||||||
|
(loop_expression)
|
||||||
|
(for_expression)
|
||||||
|
(while_expression)
|
||||||
|
(if_expression)
|
||||||
|
(match_expression)
|
||||||
|
(call_expression)
|
||||||
|
(array_expression)
|
||||||
|
(macro_definition)
|
||||||
|
(macro_invocation)
|
||||||
|
(attribute_item)
|
||||||
|
(block)
|
||||||
|
(use_declaration)+
|
||||||
|
] @fold
|
||||||
531
config/nvim/queries/rust/highlights.scm
Normal file
531
config/nvim/queries/rust/highlights.scm
Normal file
@@ -0,0 +1,531 @@
|
|||||||
|
; Forked from https://github.com/tree-sitter/tree-sitter-rust
|
||||||
|
; Copyright (c) 2017 Maxim Sokolov
|
||||||
|
; Licensed under the MIT license.
|
||||||
|
; Identifier conventions
|
||||||
|
(shebang) @keyword.directive
|
||||||
|
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
((identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
(const_item
|
||||||
|
name: (identifier) @constant)
|
||||||
|
|
||||||
|
; Assume all-caps names are constants
|
||||||
|
((identifier) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||||
|
|
||||||
|
; Other identifiers
|
||||||
|
(type_identifier) @type
|
||||||
|
|
||||||
|
(primitive_type) @type.builtin
|
||||||
|
|
||||||
|
(field_identifier) @variable.member
|
||||||
|
|
||||||
|
(shorthand_field_identifier) @variable.member
|
||||||
|
|
||||||
|
(shorthand_field_initializer
|
||||||
|
(identifier) @variable.member)
|
||||||
|
|
||||||
|
(mod_item
|
||||||
|
name: (identifier) @module)
|
||||||
|
|
||||||
|
(self) @variable.builtin
|
||||||
|
|
||||||
|
"_" @character.special
|
||||||
|
|
||||||
|
(label
|
||||||
|
[
|
||||||
|
"'"
|
||||||
|
(identifier)
|
||||||
|
] @label)
|
||||||
|
|
||||||
|
; Function definitions
|
||||||
|
(function_item
|
||||||
|
(identifier) @function)
|
||||||
|
|
||||||
|
(function_signature_item
|
||||||
|
(identifier) @function)
|
||||||
|
|
||||||
|
(parameter
|
||||||
|
[
|
||||||
|
(identifier)
|
||||||
|
"_"
|
||||||
|
] @variable.parameter)
|
||||||
|
|
||||||
|
(parameter
|
||||||
|
(ref_pattern
|
||||||
|
[
|
||||||
|
(mut_pattern
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
(identifier) @variable.parameter
|
||||||
|
]))
|
||||||
|
|
||||||
|
(closure_parameters
|
||||||
|
(_) @variable.parameter)
|
||||||
|
|
||||||
|
; Function calls
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
(identifier) @function.call .))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (field_expression
|
||||||
|
field: (field_identifier) @function.call))
|
||||||
|
|
||||||
|
(generic_function
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(generic_function
|
||||||
|
function: (scoped_identifier
|
||||||
|
name: (identifier) @function.call))
|
||||||
|
|
||||||
|
(generic_function
|
||||||
|
function: (field_expression
|
||||||
|
field: (field_identifier) @function.call))
|
||||||
|
|
||||||
|
; Assume other uppercase names are enum constructors
|
||||||
|
((field_identifier) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
|
(enum_variant
|
||||||
|
name: (identifier) @constant)
|
||||||
|
|
||||||
|
; Assume that uppercase names in paths are types
|
||||||
|
(scoped_identifier
|
||||||
|
path: (identifier) @module)
|
||||||
|
|
||||||
|
(scoped_identifier
|
||||||
|
(scoped_identifier
|
||||||
|
name: (identifier) @module))
|
||||||
|
|
||||||
|
(scoped_type_identifier
|
||||||
|
path: (identifier) @module)
|
||||||
|
|
||||||
|
(scoped_type_identifier
|
||||||
|
path: (identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
(scoped_type_identifier
|
||||||
|
(scoped_identifier
|
||||||
|
name: (identifier) @module))
|
||||||
|
|
||||||
|
((scoped_identifier
|
||||||
|
path: (identifier) @type)
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
((scoped_identifier
|
||||||
|
name: (identifier) @type)
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
((scoped_identifier
|
||||||
|
name: (identifier) @constant)
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||||
|
|
||||||
|
((scoped_identifier
|
||||||
|
path: (identifier) @type
|
||||||
|
name: (identifier) @constant)
|
||||||
|
(#lua-match? @type "^[A-Z]")
|
||||||
|
(#lua-match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
|
((scoped_type_identifier
|
||||||
|
path: (identifier) @type
|
||||||
|
name: (type_identifier) @constant)
|
||||||
|
(#lua-match? @type "^[A-Z]")
|
||||||
|
(#lua-match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
|
[
|
||||||
|
(crate)
|
||||||
|
(super)
|
||||||
|
] @module
|
||||||
|
|
||||||
|
(scoped_use_list
|
||||||
|
path: (identifier) @module)
|
||||||
|
|
||||||
|
(scoped_use_list
|
||||||
|
path: (scoped_identifier
|
||||||
|
(identifier) @module))
|
||||||
|
|
||||||
|
(use_list
|
||||||
|
(scoped_identifier
|
||||||
|
(identifier) @module
|
||||||
|
.
|
||||||
|
(_)))
|
||||||
|
|
||||||
|
(use_list
|
||||||
|
(identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
(use_as_clause
|
||||||
|
alias: (identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
; Correct enum constructors
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
"::"
|
||||||
|
name: (identifier) @constant)
|
||||||
|
(#lua-match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
|
; Assume uppercase names in a match arm are constants.
|
||||||
|
((match_arm
|
||||||
|
pattern: (match_pattern
|
||||||
|
(identifier) @constant))
|
||||||
|
(#lua-match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
|
((match_arm
|
||||||
|
pattern: (match_pattern
|
||||||
|
(scoped_identifier
|
||||||
|
name: (identifier) @constant)))
|
||||||
|
(#lua-match? @constant "^[A-Z]"))
|
||||||
|
|
||||||
|
((identifier) @constant.builtin
|
||||||
|
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
|
||||||
|
|
||||||
|
; Macro definitions
|
||||||
|
"$" @function.macro
|
||||||
|
|
||||||
|
(metavariable) @function.macro
|
||||||
|
|
||||||
|
(macro_definition
|
||||||
|
"macro_rules!" @function.macro)
|
||||||
|
|
||||||
|
; Attribute macros
|
||||||
|
(attribute_item
|
||||||
|
(attribute
|
||||||
|
(identifier) @function.macro))
|
||||||
|
|
||||||
|
(inner_attribute_item
|
||||||
|
(attribute
|
||||||
|
(identifier) @function.macro))
|
||||||
|
|
||||||
|
(attribute
|
||||||
|
(scoped_identifier
|
||||||
|
(identifier) @function.macro .))
|
||||||
|
|
||||||
|
; Derive macros (assume all arguments are types)
|
||||||
|
; (attribute
|
||||||
|
; (identifier) @_name
|
||||||
|
; arguments: (attribute (attribute (identifier) @type))
|
||||||
|
; (#eq? @_name "derive"))
|
||||||
|
; Function-like macros
|
||||||
|
(macro_invocation
|
||||||
|
macro: (identifier) @function.macro)
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
macro: (scoped_identifier
|
||||||
|
(identifier) @function.macro .))
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
(boolean_literal) @boolean
|
||||||
|
|
||||||
|
(integer_literal) @number
|
||||||
|
|
||||||
|
(float_literal) @number.float
|
||||||
|
|
||||||
|
[
|
||||||
|
(raw_string_literal)
|
||||||
|
(string_literal)
|
||||||
|
] @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
(char_literal) @character
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
[
|
||||||
|
"use"
|
||||||
|
"mod"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
(use_as_clause
|
||||||
|
"as" @keyword.import)
|
||||||
|
|
||||||
|
[
|
||||||
|
"default"
|
||||||
|
"impl"
|
||||||
|
"let"
|
||||||
|
"move"
|
||||||
|
"unsafe"
|
||||||
|
"where"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"enum"
|
||||||
|
"struct"
|
||||||
|
"union"
|
||||||
|
"trait"
|
||||||
|
"type"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
[
|
||||||
|
"async"
|
||||||
|
"await"
|
||||||
|
"gen"
|
||||||
|
] @keyword.coroutine
|
||||||
|
|
||||||
|
"try" @keyword.exception
|
||||||
|
|
||||||
|
[
|
||||||
|
"ref"
|
||||||
|
"pub"
|
||||||
|
"raw"
|
||||||
|
(mutable_specifier)
|
||||||
|
"const"
|
||||||
|
"static"
|
||||||
|
"dyn"
|
||||||
|
"extern"
|
||||||
|
] @keyword.modifier
|
||||||
|
|
||||||
|
(lifetime
|
||||||
|
"'" @keyword.modifier)
|
||||||
|
|
||||||
|
(lifetime
|
||||||
|
(identifier) @attribute)
|
||||||
|
|
||||||
|
(lifetime
|
||||||
|
(identifier) @attribute.builtin
|
||||||
|
(#any-of? @attribute.builtin "static" "_"))
|
||||||
|
|
||||||
|
"fn" @keyword.function
|
||||||
|
|
||||||
|
[
|
||||||
|
"return"
|
||||||
|
"yield"
|
||||||
|
] @keyword.return
|
||||||
|
|
||||||
|
(type_cast_expression
|
||||||
|
"as" @keyword.operator)
|
||||||
|
|
||||||
|
(qualified_type
|
||||||
|
"as" @keyword.operator)
|
||||||
|
|
||||||
|
(use_list
|
||||||
|
(self) @module)
|
||||||
|
|
||||||
|
(scoped_use_list
|
||||||
|
(self) @module)
|
||||||
|
|
||||||
|
(scoped_identifier
|
||||||
|
[
|
||||||
|
(crate)
|
||||||
|
(super)
|
||||||
|
(self)
|
||||||
|
] @module)
|
||||||
|
|
||||||
|
(visibility_modifier
|
||||||
|
[
|
||||||
|
(crate)
|
||||||
|
(super)
|
||||||
|
(self)
|
||||||
|
] @module)
|
||||||
|
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"else"
|
||||||
|
"match"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
"in"
|
||||||
|
"loop"
|
||||||
|
"while"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
"for" @keyword
|
||||||
|
|
||||||
|
(for_expression
|
||||||
|
"for" @keyword.repeat)
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
[
|
||||||
|
"!"
|
||||||
|
"!="
|
||||||
|
"%"
|
||||||
|
"%="
|
||||||
|
"&"
|
||||||
|
"&&"
|
||||||
|
"&="
|
||||||
|
"*"
|
||||||
|
"*="
|
||||||
|
"+"
|
||||||
|
"+="
|
||||||
|
"-"
|
||||||
|
"-="
|
||||||
|
".."
|
||||||
|
"..="
|
||||||
|
"..."
|
||||||
|
"/"
|
||||||
|
"/="
|
||||||
|
"<"
|
||||||
|
"<<"
|
||||||
|
"<<="
|
||||||
|
"<="
|
||||||
|
"="
|
||||||
|
"=="
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
">>"
|
||||||
|
">>="
|
||||||
|
"?"
|
||||||
|
"@"
|
||||||
|
"^"
|
||||||
|
"^="
|
||||||
|
"|"
|
||||||
|
"|="
|
||||||
|
"||"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
(use_wildcard
|
||||||
|
"*" @character.special)
|
||||||
|
|
||||||
|
(remaining_field_pattern
|
||||||
|
".." @character.special)
|
||||||
|
|
||||||
|
(range_pattern
|
||||||
|
[
|
||||||
|
".."
|
||||||
|
"..="
|
||||||
|
"..."
|
||||||
|
] @character.special)
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(closure_parameters
|
||||||
|
"|" @punctuation.bracket)
|
||||||
|
|
||||||
|
(type_arguments
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(type_parameters
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(bracketed_type
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(for_lifetimes
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
"."
|
||||||
|
":"
|
||||||
|
"::"
|
||||||
|
";"
|
||||||
|
"->"
|
||||||
|
"=>"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
(attribute_item
|
||||||
|
"#" @punctuation.special)
|
||||||
|
|
||||||
|
(inner_attribute_item
|
||||||
|
[
|
||||||
|
"!"
|
||||||
|
"#"
|
||||||
|
] @punctuation.special)
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
"!" @function.macro)
|
||||||
|
|
||||||
|
(never_type
|
||||||
|
"!" @type.builtin)
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
macro: (identifier) @_identifier @keyword.exception
|
||||||
|
"!" @keyword.exception
|
||||||
|
(#eq? @_identifier "panic"))
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
macro: (identifier) @_identifier @keyword.exception
|
||||||
|
"!" @keyword.exception
|
||||||
|
(#contains? @_identifier "assert"))
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
macro: (identifier) @_identifier @keyword.debug
|
||||||
|
"!" @keyword.debug
|
||||||
|
(#eq? @_identifier "dbg"))
|
||||||
|
|
||||||
|
; Comments
|
||||||
|
[
|
||||||
|
(line_comment)
|
||||||
|
(block_comment)
|
||||||
|
(outer_doc_comment_marker)
|
||||||
|
(inner_doc_comment_marker)
|
||||||
|
] @comment @spell
|
||||||
|
|
||||||
|
(line_comment
|
||||||
|
(doc_comment)) @comment.documentation
|
||||||
|
|
||||||
|
(block_comment
|
||||||
|
(doc_comment)) @comment.documentation
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (identifier) @_regex
|
||||||
|
(#any-of? @_regex "Regex" "ByteRegexBuilder")
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @string.regexp)))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (scoped_identifier
|
||||||
|
(identifier) @_regex
|
||||||
|
(#any-of? @_regex "Regex" "ByteRegexBuilder") .)
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @string.regexp)))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (identifier) @_regex
|
||||||
|
(#any-of? @_regex "RegexSet" "RegexSetBuilder")
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(array_expression
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @string.regexp))))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (scoped_identifier
|
||||||
|
(identifier) @_regex
|
||||||
|
(#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(array_expression
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @string.regexp))))
|
||||||
89
config/nvim/queries/rust/injections.scm
Normal file
89
config/nvim/queries/rust/injections.scm
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
(macro_invocation
|
||||||
|
macro: [
|
||||||
|
(scoped_identifier
|
||||||
|
name: (_) @_macro_name)
|
||||||
|
(identifier) @_macro_name
|
||||||
|
]
|
||||||
|
(token_tree) @injection.content
|
||||||
|
(#not-any-of? @_macro_name "slint" "html" "json")
|
||||||
|
(#set! injection.language "rust")
|
||||||
|
(#set! injection.include-children))
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
macro: [
|
||||||
|
(scoped_identifier
|
||||||
|
name: (_) @injection.language)
|
||||||
|
(identifier) @injection.language
|
||||||
|
]
|
||||||
|
(token_tree) @injection.content
|
||||||
|
(#any-of? @injection.language "slint" "html" "json")
|
||||||
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
|
(#set! injection.include-children))
|
||||||
|
|
||||||
|
(macro_definition
|
||||||
|
(macro_rule
|
||||||
|
left: (token_tree_pattern) @injection.content
|
||||||
|
(#set! injection.language "rust")))
|
||||||
|
|
||||||
|
(macro_definition
|
||||||
|
(macro_rule
|
||||||
|
right: (token_tree) @injection.content
|
||||||
|
(#set! injection.language "rust")))
|
||||||
|
|
||||||
|
([
|
||||||
|
(line_comment)
|
||||||
|
(block_comment)
|
||||||
|
] @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (identifier) @_regex
|
||||||
|
(#any-of? @_regex "Regex" "RegexBuilder")
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @injection.content))
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (scoped_identifier
|
||||||
|
(identifier) @_regex
|
||||||
|
(#any-of? @_regex "Regex" "RegexBuilder") .)
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @injection.content))
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (identifier) @_regex
|
||||||
|
(#any-of? @_regex "RegexSet" "RegexSetBuilder")
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(array_expression
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @injection.content)))
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (scoped_identifier
|
||||||
|
path: (scoped_identifier
|
||||||
|
(identifier) @_regex
|
||||||
|
(#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
|
||||||
|
name: (identifier) @_new
|
||||||
|
(#eq? @_new "new"))
|
||||||
|
arguments: (arguments
|
||||||
|
(array_expression
|
||||||
|
(raw_string_literal
|
||||||
|
(string_content) @injection.content)))
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
((block_comment) @injection.content
|
||||||
|
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||||
|
(#set! injection.language "re2c"))
|
||||||
98
config/nvim/queries/rust/locals.scm
Normal file
98
config/nvim/queries/rust/locals.scm
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
; Imports
|
||||||
|
(extern_crate_declaration
|
||||||
|
name: (identifier) @local.definition.import)
|
||||||
|
|
||||||
|
(use_declaration
|
||||||
|
argument: (scoped_identifier
|
||||||
|
name: (identifier) @local.definition.import))
|
||||||
|
|
||||||
|
(use_as_clause
|
||||||
|
alias: (identifier) @local.definition.import)
|
||||||
|
|
||||||
|
(use_list
|
||||||
|
(identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio};
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
(function_item
|
||||||
|
name: (identifier) @local.definition.function)
|
||||||
|
|
||||||
|
(function_item
|
||||||
|
name: (identifier) @local.definition.method
|
||||||
|
parameters: (parameters
|
||||||
|
(self_parameter)))
|
||||||
|
|
||||||
|
; Variables
|
||||||
|
(parameter
|
||||||
|
pattern: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(let_declaration
|
||||||
|
pattern: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(const_item
|
||||||
|
name: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(tuple_pattern
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(let_condition
|
||||||
|
pattern: (_
|
||||||
|
(identifier) @local.definition.var))
|
||||||
|
|
||||||
|
(tuple_struct_pattern
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(closure_parameters
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(self_parameter
|
||||||
|
(self) @local.definition.var)
|
||||||
|
|
||||||
|
(for_expression
|
||||||
|
pattern: (identifier) @local.definition.var)
|
||||||
|
|
||||||
|
; Types
|
||||||
|
(struct_item
|
||||||
|
name: (type_identifier) @local.definition.type)
|
||||||
|
|
||||||
|
(enum_item
|
||||||
|
name: (type_identifier) @local.definition.type)
|
||||||
|
|
||||||
|
; Fields
|
||||||
|
(field_declaration
|
||||||
|
name: (field_identifier) @local.definition.field)
|
||||||
|
|
||||||
|
(enum_variant
|
||||||
|
name: (identifier) @local.definition.field)
|
||||||
|
|
||||||
|
; References
|
||||||
|
(identifier) @local.reference
|
||||||
|
|
||||||
|
((type_identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
((field_identifier) @local.reference
|
||||||
|
(#set! reference.kind "field"))
|
||||||
|
|
||||||
|
; Macros
|
||||||
|
(macro_definition
|
||||||
|
name: (identifier) @local.definition.macro)
|
||||||
|
|
||||||
|
; Module
|
||||||
|
(mod_item
|
||||||
|
name: (identifier) @local.definition.namespace)
|
||||||
|
|
||||||
|
; Scopes
|
||||||
|
[
|
||||||
|
(block)
|
||||||
|
(function_item)
|
||||||
|
(closure_expression)
|
||||||
|
(while_expression)
|
||||||
|
(for_expression)
|
||||||
|
(loop_expression)
|
||||||
|
(if_expression)
|
||||||
|
(match_expression)
|
||||||
|
(match_arm)
|
||||||
|
(struct_item)
|
||||||
|
(enum_item)
|
||||||
|
(impl_item)
|
||||||
|
] @local.scope
|
||||||
409
config/nvim/queries/rust/textobjects.scm
Normal file
409
config/nvim/queries/rust/textobjects.scm
Normal file
@@ -0,0 +1,409 @@
|
|||||||
|
; functions
|
||||||
|
(function_signature_item) @function.outer
|
||||||
|
|
||||||
|
(function_item) @function.outer
|
||||||
|
|
||||||
|
(function_item
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; quantifies as class(es)
|
||||||
|
(struct_item) @class.outer
|
||||||
|
|
||||||
|
(struct_item
|
||||||
|
body: (field_declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(enum_item) @class.outer
|
||||||
|
|
||||||
|
(enum_item
|
||||||
|
body: (enum_variant_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(union_item) @class.outer
|
||||||
|
|
||||||
|
(union_item
|
||||||
|
body: (field_declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(trait_item) @class.outer
|
||||||
|
|
||||||
|
(trait_item
|
||||||
|
body: (declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(impl_item) @class.outer
|
||||||
|
|
||||||
|
(impl_item
|
||||||
|
body: (declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
(mod_item) @class.outer
|
||||||
|
|
||||||
|
(mod_item
|
||||||
|
body: (declaration_list
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; conditionals
|
||||||
|
(if_expression
|
||||||
|
alternative: (_
|
||||||
|
(_) @conditional.inner)?) @conditional.outer
|
||||||
|
|
||||||
|
(if_expression
|
||||||
|
alternative: (else_clause
|
||||||
|
(block) @conditional.inner))
|
||||||
|
|
||||||
|
(if_expression
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
(if_expression
|
||||||
|
consequence: (block) @conditional.inner)
|
||||||
|
|
||||||
|
(match_arm
|
||||||
|
(_)) @conditional.inner
|
||||||
|
|
||||||
|
(match_expression) @conditional.outer
|
||||||
|
|
||||||
|
; loops
|
||||||
|
(loop_expression
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(while_expression
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
(for_expression
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @loop.inner
|
||||||
|
"}")) @loop.outer
|
||||||
|
|
||||||
|
; blocks
|
||||||
|
(block
|
||||||
|
(_)* @block.inner) @block.outer
|
||||||
|
|
||||||
|
(unsafe_block
|
||||||
|
(_)* @block.inner) @block.outer
|
||||||
|
|
||||||
|
; calls
|
||||||
|
(macro_invocation) @call.outer
|
||||||
|
|
||||||
|
(macro_invocation
|
||||||
|
(token_tree
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(call_expression) @call.outer
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
.
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
|
|
||||||
|
; returns
|
||||||
|
(return_expression
|
||||||
|
(_)? @return.inner) @return.outer
|
||||||
|
|
||||||
|
; statements
|
||||||
|
(block
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
; comments
|
||||||
|
(line_comment) @comment.outer
|
||||||
|
|
||||||
|
(block_comment) @comment.outer
|
||||||
|
|
||||||
|
; parameter
|
||||||
|
(parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(self_parameter)
|
||||||
|
(parameter)
|
||||||
|
(type_identifier)
|
||||||
|
] @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(parameters
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(self_parameter)
|
||||||
|
(parameter)
|
||||||
|
(type_identifier)
|
||||||
|
] @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(parameters
|
||||||
|
[
|
||||||
|
(self_parameter)
|
||||||
|
(parameter)
|
||||||
|
(type_identifier)
|
||||||
|
] @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(type_parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(type_parameters
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(type_parameters
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(tuple_pattern
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(identifier) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(tuple_pattern
|
||||||
|
.
|
||||||
|
(identifier) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(tuple_pattern
|
||||||
|
(identifier) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(tuple_struct_pattern
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(identifier) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(tuple_struct_pattern
|
||||||
|
.
|
||||||
|
(identifier) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(tuple_struct_pattern
|
||||||
|
(identifier) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(tuple_expression
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(tuple_expression
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(tuple_expression
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(tuple_type
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(tuple_type
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(tuple_type
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(struct_item
|
||||||
|
body: (field_declaration_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer))
|
||||||
|
|
||||||
|
(struct_item
|
||||||
|
body: (field_declaration_list
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer))
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(struct_item
|
||||||
|
body: (field_declaration_list
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .))
|
||||||
|
|
||||||
|
(struct_expression
|
||||||
|
body: (field_initializer_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer))
|
||||||
|
|
||||||
|
(struct_expression
|
||||||
|
body: (field_initializer_list
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer))
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(struct_expression
|
||||||
|
body: (field_initializer_list
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .))
|
||||||
|
|
||||||
|
(closure_parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(closure_parameters
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(closure_parameters
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(arguments
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(arguments
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(arguments
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(type_arguments
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(type_arguments
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(type_arguments
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(token_tree
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(token_tree
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(token_tree
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .)
|
||||||
|
|
||||||
|
(scoped_use_list
|
||||||
|
list: (use_list
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer))
|
||||||
|
|
||||||
|
(scoped_use_list
|
||||||
|
list: (use_list
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer))
|
||||||
|
|
||||||
|
; last element, with trailing comma
|
||||||
|
(scoped_use_list
|
||||||
|
list: (use_list
|
||||||
|
(_) @parameter.outer
|
||||||
|
.
|
||||||
|
"," @parameter.outer .))
|
||||||
|
|
||||||
|
[
|
||||||
|
(integer_literal)
|
||||||
|
(float_literal)
|
||||||
|
] @number.inner
|
||||||
|
|
||||||
|
(let_declaration
|
||||||
|
pattern: (_) @assignment.lhs
|
||||||
|
value: (_) @assignment.inner @assignment.rhs) @assignment.outer
|
||||||
|
|
||||||
|
(let_declaration
|
||||||
|
pattern: (_) @assignment.inner)
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
left: (_) @assignment.lhs
|
||||||
|
right: (_) @assignment.inner @assignment.rhs) @assignment.outer
|
||||||
|
|
||||||
|
(assignment_expression
|
||||||
|
left: (_) @assignment.inner)
|
||||||
23
config/nvim/queries/zig/folds.scm
Normal file
23
config/nvim/queries/zig/folds.scm
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[
|
||||||
|
(block)
|
||||||
|
(switch_expression)
|
||||||
|
(initializer_list)
|
||||||
|
(asm_expression)
|
||||||
|
(multiline_string)
|
||||||
|
(if_statement)
|
||||||
|
(while_statement)
|
||||||
|
(for_statement)
|
||||||
|
(if_expression)
|
||||||
|
(else_clause)
|
||||||
|
(for_expression)
|
||||||
|
(while_expression)
|
||||||
|
(if_type_expression)
|
||||||
|
(function_signature)
|
||||||
|
(parameters)
|
||||||
|
(call_expression)
|
||||||
|
(struct_declaration)
|
||||||
|
(opaque_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(union_declaration)
|
||||||
|
(error_set_declaration)
|
||||||
|
] @fold
|
||||||
283
config/nvim/queries/zig/highlights.scm
Normal file
283
config/nvim/queries/zig/highlights.scm
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
; Variables
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
(parameter
|
||||||
|
name: (identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(payload
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
; Types
|
||||||
|
(parameter
|
||||||
|
type: (identifier) @type)
|
||||||
|
|
||||||
|
((identifier) @type
|
||||||
|
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @type
|
||||||
|
"="
|
||||||
|
[
|
||||||
|
(struct_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(union_declaration)
|
||||||
|
(opaque_declaration)
|
||||||
|
])
|
||||||
|
|
||||||
|
[
|
||||||
|
(builtin_type)
|
||||||
|
"anyframe"
|
||||||
|
] @type.builtin
|
||||||
|
|
||||||
|
; Constants
|
||||||
|
((identifier) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
|
||||||
|
|
||||||
|
[
|
||||||
|
"null"
|
||||||
|
"unreachable"
|
||||||
|
"undefined"
|
||||||
|
] @constant.builtin
|
||||||
|
|
||||||
|
(field_expression
|
||||||
|
.
|
||||||
|
member: (identifier) @constant)
|
||||||
|
|
||||||
|
(enum_declaration
|
||||||
|
(container_field
|
||||||
|
type: (identifier) @constant))
|
||||||
|
|
||||||
|
; Labels
|
||||||
|
(block_label
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
(break_label
|
||||||
|
(identifier) @label)
|
||||||
|
|
||||||
|
; Fields
|
||||||
|
(field_initializer
|
||||||
|
.
|
||||||
|
(identifier) @variable.member)
|
||||||
|
|
||||||
|
(field_expression
|
||||||
|
(_)
|
||||||
|
member: (identifier) @variable.member)
|
||||||
|
|
||||||
|
(container_field
|
||||||
|
name: (identifier) @variable.member)
|
||||||
|
|
||||||
|
(initializer_list
|
||||||
|
(assignment_expression
|
||||||
|
left: (field_expression
|
||||||
|
.
|
||||||
|
member: (identifier) @variable.member)))
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
(builtin_identifier) @function.builtin
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function.call)
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (field_expression
|
||||||
|
member: (identifier) @function.call))
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @function)
|
||||||
|
|
||||||
|
; Modules
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @module
|
||||||
|
(builtin_function
|
||||||
|
(builtin_identifier) @keyword.import
|
||||||
|
(#any-of? @keyword.import "@import" "@cImport")))
|
||||||
|
|
||||||
|
; Builtins
|
||||||
|
[
|
||||||
|
"c"
|
||||||
|
"..."
|
||||||
|
] @variable.builtin
|
||||||
|
|
||||||
|
((identifier) @variable.builtin
|
||||||
|
(#eq? @variable.builtin "_"))
|
||||||
|
|
||||||
|
(calling_convention
|
||||||
|
(identifier) @variable.builtin)
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
[
|
||||||
|
"asm"
|
||||||
|
"defer"
|
||||||
|
"errdefer"
|
||||||
|
"test"
|
||||||
|
"error"
|
||||||
|
"const"
|
||||||
|
"var"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"struct"
|
||||||
|
"union"
|
||||||
|
"enum"
|
||||||
|
"opaque"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
[
|
||||||
|
"async"
|
||||||
|
"await"
|
||||||
|
"suspend"
|
||||||
|
"nosuspend"
|
||||||
|
"resume"
|
||||||
|
] @keyword.coroutine
|
||||||
|
|
||||||
|
"fn" @keyword.function
|
||||||
|
|
||||||
|
[
|
||||||
|
"and"
|
||||||
|
"or"
|
||||||
|
"orelse"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
"return" @keyword.return
|
||||||
|
|
||||||
|
[
|
||||||
|
"if"
|
||||||
|
"else"
|
||||||
|
"switch"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"while"
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"usingnamespace"
|
||||||
|
"export"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
"try"
|
||||||
|
"catch"
|
||||||
|
] @keyword.exception
|
||||||
|
|
||||||
|
[
|
||||||
|
"volatile"
|
||||||
|
"allowzero"
|
||||||
|
"noalias"
|
||||||
|
"addrspace"
|
||||||
|
"align"
|
||||||
|
"callconv"
|
||||||
|
"linksection"
|
||||||
|
"pub"
|
||||||
|
"inline"
|
||||||
|
"noinline"
|
||||||
|
"extern"
|
||||||
|
"comptime"
|
||||||
|
"packed"
|
||||||
|
"threadlocal"
|
||||||
|
] @keyword.modifier
|
||||||
|
|
||||||
|
; Operator
|
||||||
|
[
|
||||||
|
"="
|
||||||
|
"*="
|
||||||
|
"*%="
|
||||||
|
"*|="
|
||||||
|
"/="
|
||||||
|
"%="
|
||||||
|
"+="
|
||||||
|
"+%="
|
||||||
|
"+|="
|
||||||
|
"-="
|
||||||
|
"-%="
|
||||||
|
"-|="
|
||||||
|
"<<="
|
||||||
|
"<<|="
|
||||||
|
">>="
|
||||||
|
"&="
|
||||||
|
"^="
|
||||||
|
"|="
|
||||||
|
"!"
|
||||||
|
"~"
|
||||||
|
"-"
|
||||||
|
"-%"
|
||||||
|
"&"
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
"<="
|
||||||
|
"<"
|
||||||
|
"&"
|
||||||
|
"^"
|
||||||
|
"|"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"<<|"
|
||||||
|
"+"
|
||||||
|
"++"
|
||||||
|
"+%"
|
||||||
|
"-%"
|
||||||
|
"+|"
|
||||||
|
"-|"
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
|
"**"
|
||||||
|
"*%"
|
||||||
|
"*|"
|
||||||
|
"||"
|
||||||
|
".*"
|
||||||
|
".?"
|
||||||
|
"?"
|
||||||
|
".."
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
(character) @character
|
||||||
|
|
||||||
|
([
|
||||||
|
(string)
|
||||||
|
(multiline_string)
|
||||||
|
] @string
|
||||||
|
(#set! "priority" 95))
|
||||||
|
|
||||||
|
(integer) @number
|
||||||
|
|
||||||
|
(float) @number.float
|
||||||
|
|
||||||
|
(boolean) @boolean
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
|
[
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
";"
|
||||||
|
"."
|
||||||
|
","
|
||||||
|
":"
|
||||||
|
"=>"
|
||||||
|
"->"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
(payload
|
||||||
|
"|" @punctuation.bracket)
|
||||||
|
|
||||||
|
; Comments
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
((comment) @comment.documentation
|
||||||
|
(#lua-match? @comment.documentation "^//!"))
|
||||||
10
config/nvim/queries/zig/injections.scm
Normal file
10
config/nvim/queries/zig/injections.scm
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; TODO: add when asm is added
|
||||||
|
; (asm_output_item (string) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
; (asm_input_item (string) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
; (asm_clobbers (string) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
96
config/nvim/queries/zig/locals.scm
Normal file
96
config/nvim/queries/zig/locals.scm
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
; Definitions
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @local.definition.function)
|
||||||
|
|
||||||
|
(parameter
|
||||||
|
name: (identifier) @local.definition.parameter)
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @local.definition.type
|
||||||
|
(enum_declaration))
|
||||||
|
|
||||||
|
(container_field
|
||||||
|
type: (identifier) @local.definition.field)
|
||||||
|
|
||||||
|
(enum_declaration
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @local.definition.method))
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @local.definition.type
|
||||||
|
(struct_declaration))
|
||||||
|
|
||||||
|
(struct_declaration
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @local.definition.method))
|
||||||
|
|
||||||
|
(container_field
|
||||||
|
name: (identifier) @local.definition.field)
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(identifier) @local.definition.type
|
||||||
|
(union_declaration))
|
||||||
|
|
||||||
|
(union_declaration
|
||||||
|
(function_declaration
|
||||||
|
name: (identifier) @local.definition.method))
|
||||||
|
|
||||||
|
(payload
|
||||||
|
(identifier) @local.definition.var)
|
||||||
|
|
||||||
|
(block_label
|
||||||
|
(identifier) @local.definition)
|
||||||
|
|
||||||
|
; References
|
||||||
|
(identifier) @local.reference
|
||||||
|
|
||||||
|
(parameter
|
||||||
|
type: (identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(pointer_type
|
||||||
|
(identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(nullable_type
|
||||||
|
(identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(struct_initializer
|
||||||
|
(identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(array_type
|
||||||
|
(_)
|
||||||
|
(identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(slice_type
|
||||||
|
(identifier) @local.reference
|
||||||
|
(#set! reference.kind "type"))
|
||||||
|
|
||||||
|
(field_expression
|
||||||
|
member: (identifier) @local.reference
|
||||||
|
(#set! reference.kind "field"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (field_expression
|
||||||
|
member: (identifier) @local.reference
|
||||||
|
(#set! reference.kind "function")))
|
||||||
|
|
||||||
|
(break_label
|
||||||
|
(identifier) @local.reference)
|
||||||
|
|
||||||
|
[
|
||||||
|
(for_statement)
|
||||||
|
(if_statement)
|
||||||
|
(while_statement)
|
||||||
|
(function_declaration)
|
||||||
|
(block)
|
||||||
|
(source_file)
|
||||||
|
(enum_declaration)
|
||||||
|
(struct_declaration)
|
||||||
|
] @local.scope
|
||||||
110
config/nvim/queries/zig/textobjects.scm
Normal file
110
config/nvim/queries/zig/textobjects.scm
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
; "Classes"
|
||||||
|
(variable_declaration
|
||||||
|
(struct_declaration)) @class.outer
|
||||||
|
|
||||||
|
(variable_declaration
|
||||||
|
(struct_declaration
|
||||||
|
"struct"
|
||||||
|
"{"
|
||||||
|
_+ @class.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; functions
|
||||||
|
(function_declaration) @function.outer
|
||||||
|
|
||||||
|
(function_declaration
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
"{"
|
||||||
|
_+ @function.inner
|
||||||
|
"}"))
|
||||||
|
|
||||||
|
; loops
|
||||||
|
(for_statement) @loop.outer
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
body: (_) @loop.inner)
|
||||||
|
|
||||||
|
(while_statement) @loop.outer
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
body: (_) @loop.inner)
|
||||||
|
|
||||||
|
; blocks
|
||||||
|
(block) @block.outer
|
||||||
|
|
||||||
|
(block
|
||||||
|
"{"
|
||||||
|
_+ @block.inner
|
||||||
|
"}")
|
||||||
|
|
||||||
|
; statements
|
||||||
|
(statement) @statement.outer
|
||||||
|
|
||||||
|
; parameters
|
||||||
|
(parameters
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(parameter) @parameter.inner @parameter.outer)
|
||||||
|
|
||||||
|
(parameters
|
||||||
|
.
|
||||||
|
(parameter) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer)
|
||||||
|
|
||||||
|
; arguments
|
||||||
|
(call_expression
|
||||||
|
function: (_)
|
||||||
|
arguments: (arguments
|
||||||
|
"("
|
||||||
|
"," @parameter.outer
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (_)
|
||||||
|
arguments: (arguments
|
||||||
|
"("
|
||||||
|
.
|
||||||
|
(_) @parameter.inner @parameter.outer
|
||||||
|
.
|
||||||
|
","? @parameter.outer
|
||||||
|
")"))
|
||||||
|
|
||||||
|
; comments
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
; conditionals
|
||||||
|
(if_statement) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
body: (_) @conditional.inner)
|
||||||
|
|
||||||
|
(switch_expression) @conditional.outer
|
||||||
|
|
||||||
|
(switch_expression
|
||||||
|
"("
|
||||||
|
(_) @conditional.inner
|
||||||
|
")")
|
||||||
|
|
||||||
|
(switch_expression
|
||||||
|
"{"
|
||||||
|
_+ @conditional.inner
|
||||||
|
"}")
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
; calls
|
||||||
|
(call_expression) @call.outer
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
arguments: (arguments
|
||||||
|
"("
|
||||||
|
_+ @call.inner
|
||||||
|
")"))
|
||||||
1
config/qtile/.gitignore
vendored
Normal file
1
config/qtile/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__pycache__
|
||||||
296
config/qtile/config.py
Normal file
296
config/qtile/config.py
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
from libqtile import bar, extension, hook, layout, qtile, widget
|
||||||
|
from libqtile.config import Click, Drag, Group, Key, KeyChord, Match, Screen
|
||||||
|
from libqtile.lazy import lazy
|
||||||
|
from libqtile.utils import guess_terminal
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
mod = "mod4"
|
||||||
|
terminal = guess_terminal()
|
||||||
|
|
||||||
|
myTerm = "alacritty"
|
||||||
|
|
||||||
|
keys = [
|
||||||
|
Key([mod], "h", lazy.layout.left(), desc="Move focus to left"),
|
||||||
|
Key([mod], "l", lazy.layout.right(), desc="Move focus to right"),
|
||||||
|
Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
|
||||||
|
Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
|
||||||
|
Key([mod], "space", lazy.layout.next(), desc="Move window focus to other window"),
|
||||||
|
# Move windows between left/right columns or move up/down in current stack.
|
||||||
|
# Moving out of range in Columns layout will create new column.
|
||||||
|
Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window to the left"),
|
||||||
|
Key([mod, "shift"], "l", lazy.layout.shuffle_right(), desc="Move window to the right"),
|
||||||
|
Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down"),
|
||||||
|
Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"),
|
||||||
|
# Grow windows. If current window is on the edge of screen and direction
|
||||||
|
# will be to screen edge - window would shrink.
|
||||||
|
Key([mod, "control"], "h", lazy.layout.grow_left(), desc="Grow window to the left"),
|
||||||
|
Key([mod, "control"], "l", lazy.layout.grow_right(), desc="Grow window to the right"),
|
||||||
|
Key([mod, "control"], "j", lazy.layout.grow_down(), desc="Grow window down"),
|
||||||
|
Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"),
|
||||||
|
Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
|
||||||
|
# Toggle between split and unsplit sides of stack.
|
||||||
|
# Split = all windows displayed
|
||||||
|
# Unsplit = 1 window displayed, like Max layout, but still with
|
||||||
|
# multiple stack panes
|
||||||
|
Key(
|
||||||
|
[mod, "shift"],
|
||||||
|
"Return",
|
||||||
|
lazy.layout.toggle_split(),
|
||||||
|
desc="Toggle between split and unsplit sides of stack",
|
||||||
|
),
|
||||||
|
Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"),
|
||||||
|
# Toggle between different layouts as defined below
|
||||||
|
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
|
||||||
|
Key([mod], "q", lazy.window.kill(), desc="Kill focused window"),
|
||||||
|
Key(
|
||||||
|
[mod],
|
||||||
|
"f",
|
||||||
|
lazy.window.toggle_fullscreen(),
|
||||||
|
desc="Toggle fullscreen on the focused window",
|
||||||
|
),
|
||||||
|
Key([mod], "t", lazy.window.toggle_floating(), desc="Toggle floating on the focused window"),
|
||||||
|
Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"),
|
||||||
|
Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"),
|
||||||
|
Key([mod], "d", lazy.spawn("rofi -show drun -show-icons"), desc='Run Launcher'),
|
||||||
|
Key(
|
||||||
|
[mod],
|
||||||
|
"s",
|
||||||
|
lazy.spawn('sh -c "maim -s | xclip -selection clipboard -t image/png -i"'),
|
||||||
|
desc="Screenshot"
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Add key bindings to switch VTs in Wayland.
|
||||||
|
# We can't check qtile.core.name in default config as it is loaded before qtile is started
|
||||||
|
# We therefore defer the check until the key binding is run by using .when(func=...)
|
||||||
|
for vt in range(1, 8):
|
||||||
|
keys.append(
|
||||||
|
Key(
|
||||||
|
["control", "mod1"],
|
||||||
|
f"f{vt}",
|
||||||
|
lazy.core.change_vt(vt).when(func=lambda: qtile.core.name == "wayland"),
|
||||||
|
desc=f"Switch to VT{vt}",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
groups = [Group(i) for i in "123456789"]
|
||||||
|
|
||||||
|
for i in groups:
|
||||||
|
keys.extend(
|
||||||
|
[
|
||||||
|
# mod + group number = switch to group
|
||||||
|
Key(
|
||||||
|
[mod],
|
||||||
|
i.name,
|
||||||
|
lazy.group[i.name].toscreen(),
|
||||||
|
desc=f"Switch to group {i.name}",
|
||||||
|
),
|
||||||
|
# mod + shift + group number = switch to & move focused window to group
|
||||||
|
# Key(
|
||||||
|
# [mod, "shift"],
|
||||||
|
# i.name,
|
||||||
|
# lazy.window.togroup(i.name, switch_group=True),
|
||||||
|
# desc=f"Switch to & move focused window to group {i.name}",
|
||||||
|
# ),
|
||||||
|
# Or, use below if you prefer not to switch to that group.
|
||||||
|
# # mod + shift + group number = move focused window to group
|
||||||
|
Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
|
||||||
|
desc="move focused window to group {}".format(i.name)),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
colors = [
|
||||||
|
["#1a1b26", "#1a1b26"], # bg (primary.background)
|
||||||
|
["#a9b1d6", "#a9b1d6"], # fg (primary.foreground)
|
||||||
|
["#32344a", "#32344a"], # color01 (normal.black)
|
||||||
|
["#f7768e", "#f7768e"], # color02 (normal.red)
|
||||||
|
["#9ece6a", "#9ece6a"], # color03 (normal.green)
|
||||||
|
["#e0af68", "#e0af68"], # color04 (normal.yellow)
|
||||||
|
["#7aa2f7", "#7aa2f7"], # color05 (normal.blue)
|
||||||
|
["#ad8ee6", "#ad8ee6"], # color06 (normal.magenta)
|
||||||
|
["#0db9d7", "#0db9d7"], # color15 (bright.cyan)
|
||||||
|
["#444b6a", "#444b6a"] # color[9] (bright.black)
|
||||||
|
]
|
||||||
|
|
||||||
|
# helper in case your colors are ["#hex", "#hex"]
|
||||||
|
def C(x): return x[0] if isinstance(x, (list, tuple)) else x
|
||||||
|
|
||||||
|
layout_theme = {
|
||||||
|
"border_width" : 1,
|
||||||
|
"margin" : 1,
|
||||||
|
"border_focus" : colors[6],
|
||||||
|
"border_normal" : colors[0],
|
||||||
|
}
|
||||||
|
|
||||||
|
layouts = [
|
||||||
|
layout.Columns(**layout_theme),
|
||||||
|
layout.Max(),
|
||||||
|
# Try more layouts by unleashing below layouts.
|
||||||
|
# layout.Stack(num_stacks=2),
|
||||||
|
# layout.Bsp(),
|
||||||
|
layout.Matrix(),
|
||||||
|
# layout.MonadTall(**layout_theme),
|
||||||
|
# layout.MonadWide(),
|
||||||
|
# layout.RatioTile(),
|
||||||
|
# layout.Tile(),
|
||||||
|
# layout.TreeTab(),
|
||||||
|
# layout.VerticalTile(),
|
||||||
|
# layout.Zoomy(),
|
||||||
|
]
|
||||||
|
|
||||||
|
widget_defaults = dict(
|
||||||
|
font="JetBrainsMono Nerd Font Propo Bold",
|
||||||
|
fontsize=12,
|
||||||
|
padding=0,
|
||||||
|
background=colors[0],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
extension_defaults = widget_defaults.copy()
|
||||||
|
|
||||||
|
def make_sep():
|
||||||
|
return widget.Sep(linewidth=1, padding=8, foreground=colors[9])
|
||||||
|
|
||||||
|
def make_top_bar(primary=False):
|
||||||
|
widgets = [
|
||||||
|
widget.Spacer(length = 8),
|
||||||
|
widget.Image(
|
||||||
|
filename = "~/.config/qtile/icons/tonybtw.png",
|
||||||
|
scale = "False",
|
||||||
|
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn("qtilekeys-yad")},
|
||||||
|
),
|
||||||
|
widget.Prompt(
|
||||||
|
font = "Ubuntu Mono",
|
||||||
|
fontsize=14,
|
||||||
|
foreground = colors[1]
|
||||||
|
),
|
||||||
|
widget.GroupBox(
|
||||||
|
fontsize = 14,
|
||||||
|
margin_y = 5,
|
||||||
|
margin_x = 5,
|
||||||
|
padding_y = 0,
|
||||||
|
padding_x = 2,
|
||||||
|
borderwidth = 3,
|
||||||
|
active = colors[8],
|
||||||
|
inactive = colors[9],
|
||||||
|
rounded = False,
|
||||||
|
highlight_color = colors[0],
|
||||||
|
highlight_method = "line",
|
||||||
|
this_current_screen_border = colors[7],
|
||||||
|
this_screen_border = colors [4],
|
||||||
|
other_current_screen_border = colors[7],
|
||||||
|
other_screen_border = colors[4],
|
||||||
|
),
|
||||||
|
widget.TextBox(
|
||||||
|
text = '|',
|
||||||
|
font = "JetBrainsMono Nerd Font Propo Bold",
|
||||||
|
foreground = colors[9],
|
||||||
|
padding = 2,
|
||||||
|
fontsize = 14
|
||||||
|
),
|
||||||
|
widget.CurrentLayout(
|
||||||
|
foreground = colors[1],
|
||||||
|
padding = 5
|
||||||
|
),
|
||||||
|
widget.TextBox(
|
||||||
|
text = '|',
|
||||||
|
font = "JetBrainsMono Nerd Font Propo Bold",
|
||||||
|
foreground = colors[9],
|
||||||
|
padding = 2,
|
||||||
|
fontsize = 14
|
||||||
|
),
|
||||||
|
widget.WindowName(
|
||||||
|
foreground = colors[6],
|
||||||
|
padding = 8,
|
||||||
|
max_chars = 40
|
||||||
|
),
|
||||||
|
widget.GenPollText(
|
||||||
|
update_interval = 300,
|
||||||
|
func = lambda: subprocess.check_output("printf $(uname -r)", shell=True, text=True),
|
||||||
|
foreground = colors[3],
|
||||||
|
padding = 8,
|
||||||
|
fmt = '{}',
|
||||||
|
),
|
||||||
|
make_sep(),
|
||||||
|
widget.CPU(
|
||||||
|
foreground = colors[4],
|
||||||
|
padding = 8,
|
||||||
|
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e btop')},
|
||||||
|
format="CPU: {load_percent}%",
|
||||||
|
),
|
||||||
|
make_sep(),
|
||||||
|
widget.Memory(
|
||||||
|
foreground = colors[8],
|
||||||
|
padding = 8,
|
||||||
|
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e btop')},
|
||||||
|
format = 'Mem: {MemUsed:.0f}{mm}',
|
||||||
|
),
|
||||||
|
make_sep(),
|
||||||
|
widget.Volume(
|
||||||
|
foreground = colors[7],
|
||||||
|
padding = 8,
|
||||||
|
fmt = 'Vol: {}',
|
||||||
|
),
|
||||||
|
make_sep(),
|
||||||
|
widget.Clock(
|
||||||
|
foreground = colors[8],
|
||||||
|
padding = 8,
|
||||||
|
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn('notify-date')},
|
||||||
|
format = "%a, %b %d - %H:%M",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
if primary:
|
||||||
|
widgets.append(widget.Systray(padding = 6))
|
||||||
|
widgets.append(widget.Spacer(length = 8))
|
||||||
|
return bar.Bar(widgets, margin=[0, 0, 0, 0], size=30)
|
||||||
|
|
||||||
|
|
||||||
|
screens = [
|
||||||
|
Screen(top = make_top_bar()),
|
||||||
|
Screen(top = make_top_bar(primary=True)),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Drag floating layouts.
|
||||||
|
mouse = [
|
||||||
|
Drag([mod], "Button1", lazy.window.set_position_floating(), start=lazy.window.get_position()),
|
||||||
|
Drag([mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()),
|
||||||
|
Click([mod], "Button2", lazy.window.bring_to_front()),
|
||||||
|
]
|
||||||
|
|
||||||
|
dgroups_key_binder = None
|
||||||
|
dgroups_app_rules = [] # type: list
|
||||||
|
follow_mouse_focus = True
|
||||||
|
bring_front_click = False
|
||||||
|
floats_kept_above = True
|
||||||
|
cursor_warp = False
|
||||||
|
floating_layout = layout.Floating(
|
||||||
|
float_rules=[
|
||||||
|
# Run the utility of `xprop` to see the wm class and name of an X client.
|
||||||
|
*layout.Floating.default_float_rules,
|
||||||
|
Match(wm_class="confirmreset"), # gitk
|
||||||
|
Match(wm_class="makebranch"), # gitk
|
||||||
|
Match(wm_class="maketag"), # gitk
|
||||||
|
Match(wm_class="ssh-askpass"), # ssh-askpass
|
||||||
|
Match(title="branchdialog"), # gitk
|
||||||
|
Match(title="pinentry"), # GPG key password entry
|
||||||
|
]
|
||||||
|
)
|
||||||
|
auto_fullscreen = True
|
||||||
|
focus_on_window_activation = "smart"
|
||||||
|
reconfigure_screens = True
|
||||||
|
|
||||||
|
# If things like steam games want to auto-minimize themselves when losing
|
||||||
|
# focus, should we respect this or not?
|
||||||
|
auto_minimize = True
|
||||||
|
|
||||||
|
# When using the Wayland backend, this can be used to configure input devices.
|
||||||
|
wl_input_rules = None
|
||||||
|
|
||||||
|
# xcursor theme (string or None) and size (integer) for Wayland backend
|
||||||
|
wl_xcursor_theme = None
|
||||||
|
wl_xcursor_size = 24
|
||||||
|
|
||||||
|
wmname = "LG3D"
|
||||||
BIN
config/qtile/icons/debian.png
Normal file
BIN
config/qtile/icons/debian.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
config/qtile/icons/tonybtw.png
Normal file
BIN
config/qtile/icons/tonybtw.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
115
configuration.nix
Normal file
115
configuration.nix
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ # Include the results of the hardware scan.
|
||||||
|
./hardware-configuration.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
# Use the systemd-boot EFI boot loader.
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
networking.hostName = "hivebrain"; # Define your hostname.
|
||||||
|
|
||||||
|
# Configure network connections interactively with nmcli or nmtui.
|
||||||
|
networking.networkmanager.enable = true;
|
||||||
|
|
||||||
|
# Set your time zone.
|
||||||
|
time.timeZone = "Europe/Berlin";
|
||||||
|
|
||||||
|
# Select internationalisation properties.
|
||||||
|
# i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
# console = {
|
||||||
|
# font = "Lat2-Terminus16";
|
||||||
|
# keyMap = "de";
|
||||||
|
# useXkbConfig = true; # use xkb.options in tty.
|
||||||
|
# };
|
||||||
|
|
||||||
|
# Enable the X11 windowing system.
|
||||||
|
# services.xserver.enable = true;
|
||||||
|
|
||||||
|
services.xserver = {
|
||||||
|
enable = true;
|
||||||
|
autoRepeatDelay = 200;
|
||||||
|
autoRepeatInterval = 35;
|
||||||
|
windowManager.qtile.enable = true;
|
||||||
|
displayManager.sessionCommands = ''
|
||||||
|
xwallpaper --zoom ~/Downloads/NixOsWallpaper.png
|
||||||
|
'';
|
||||||
|
xrandrHeads = [
|
||||||
|
{
|
||||||
|
output = "HDMI-1";
|
||||||
|
monitorConfig = ''
|
||||||
|
Option "Position" "0 0"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
output = "DP-1";
|
||||||
|
primary = true;
|
||||||
|
monitorConfig = ''
|
||||||
|
Option "Position" "1920 0"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.displayManager.ly.enable = true;
|
||||||
|
|
||||||
|
fonts.packages = with pkgs; [
|
||||||
|
jetbrains-mono
|
||||||
|
];
|
||||||
|
|
||||||
|
# Enable sound.
|
||||||
|
# services.pulseaudio.enable = true;
|
||||||
|
# OR
|
||||||
|
# services.pipewire = {
|
||||||
|
# enable = true;
|
||||||
|
# pulse.enable = true;
|
||||||
|
# };
|
||||||
|
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||||
|
users.users.marvin = {
|
||||||
|
isNormalUser = true;
|
||||||
|
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
|
||||||
|
shell = pkgs.zsh;
|
||||||
|
packages = with pkgs; [
|
||||||
|
tree
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.firefox.enable = true;
|
||||||
|
programs.zsh.enable = true;
|
||||||
|
|
||||||
|
# List packages installed in system profile.
|
||||||
|
# You can use https://search.nixos.org/ to find more packages (and options).
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
vim
|
||||||
|
wget
|
||||||
|
alacritty
|
||||||
|
btop
|
||||||
|
obsidian
|
||||||
|
claude-code
|
||||||
|
jq # used by the Claude vault bootstrap.sh to parse settings.json
|
||||||
|
];
|
||||||
|
|
||||||
|
nix.settings.experimental-features = ["nix-command" "flakes"];
|
||||||
|
|
||||||
|
# Some programs need SUID wrappers, can be configured further or are
|
||||||
|
# started in user sessions.
|
||||||
|
# programs.mtr.enable = true;
|
||||||
|
# programs.gnupg.agent = {
|
||||||
|
# enable = true;
|
||||||
|
# enableSSHSupport = true;
|
||||||
|
# };
|
||||||
|
|
||||||
|
# List services that you want to enable:
|
||||||
|
|
||||||
|
# Enable the OpenSSH daemon.
|
||||||
|
services.openssh.enable = true;
|
||||||
|
|
||||||
|
system.stateVersion = "26.05";
|
||||||
|
}
|
||||||
|
|
||||||
47
flake.lock
generated
Normal file
47
flake.lock
generated
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1781981105,
|
||||||
|
"narHash": "sha256-/1nNBbA7PrSQpTc9Qazkhl4kIPg+TNl0CjxS3UQJKlw=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "7bfff44b465909f69a442701293bc0badcf476dc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"ref": "release-26.05",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1782375420,
|
||||||
|
"narHash": "sha256-f+/IH5ng5P91VHrhcNxqpW2RYDySD68V1fcX00COQy4=",
|
||||||
|
"rev": "4062d36ebeae843c750011eef6b61ec9a9dbc9a9",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.3250.4062d36ebeae/nixexprs.tar.xz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-26.05",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"home-manager": "home-manager",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
28
flake.nix
Normal file
28
flake.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
description = "Personal NixOS Setup";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-26.05";
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager/release-26.05";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, home-manager, ... }: {
|
||||||
|
nixosConfigurations.hivebrain = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
home-manager.nixosModules.home-manager {
|
||||||
|
home-manager = {
|
||||||
|
useGlobalPkgs = true;
|
||||||
|
useUserPackages = true;
|
||||||
|
users.marvin = import ./home.nix;
|
||||||
|
backupFileExtension = "backup";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
36
hardware-configuration.nix
Normal file
36
hardware-configuration.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
|
# and may be overwritten by future invocations. Please make changes
|
||||||
|
# to /etc/nixos/configuration.nix instead.
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-amd" ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
hardware.graphics.enable = true;
|
||||||
|
hardware.graphics.enable32Bit = true;
|
||||||
|
|
||||||
|
fileSystems."/" =
|
||||||
|
{ device = "/dev/disk/by-uuid/e9f91ba2-1d73-47ed-a37e-b847a9723b0f";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/boot" =
|
||||||
|
{ device = "/dev/disk/by-uuid/776C-43F7";
|
||||||
|
fsType = "vfat";
|
||||||
|
options = [ "fmask=0022" "dmask=0022" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices =
|
||||||
|
[ { device = "/dev/disk/by-uuid/d4f6670c-97e8-4297-aeec-99ade922f133"; }
|
||||||
|
];
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
}
|
||||||
71
home.nix
Normal file
71
home.nix
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
home.username = "marvin";
|
||||||
|
home.homeDirectory = "/home/marvin";
|
||||||
|
home.stateVersion = "26.05";
|
||||||
|
programs = {
|
||||||
|
yazi.enable = true;
|
||||||
|
|
||||||
|
git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "MDietermann";
|
||||||
|
userEmail = "marvin.dietermann@hive-brain.de";
|
||||||
|
};
|
||||||
|
|
||||||
|
rofi = {
|
||||||
|
enable = true;
|
||||||
|
theme = "purple";
|
||||||
|
font = "sans-serif";
|
||||||
|
package = pkgs.rofi;
|
||||||
|
modes = [
|
||||||
|
"drun"
|
||||||
|
"run"
|
||||||
|
"window"
|
||||||
|
"ssh"
|
||||||
|
];
|
||||||
|
extraConfig = {
|
||||||
|
show-icons = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
zsh = {
|
||||||
|
enable = true;
|
||||||
|
enableCompletion = true;
|
||||||
|
autosuggestion.enable = true;
|
||||||
|
syntaxHighlighting.enable = true;
|
||||||
|
|
||||||
|
history.size = 10000;
|
||||||
|
history.ignoreAllDups = true;
|
||||||
|
history.path = "$HOME/.zsh_history";
|
||||||
|
|
||||||
|
oh-my-zsh = {
|
||||||
|
enable = true;
|
||||||
|
plugins = [ "git" "sudo" ];
|
||||||
|
theme = "aussiegeek";
|
||||||
|
};
|
||||||
|
|
||||||
|
shellAliases = {
|
||||||
|
btw = "echo I use NixOS";
|
||||||
|
reload-nixos = "sudo nixos-rebuild switch --flake ~/nixos-dotfiles#hivebrain";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home.file = {
|
||||||
|
".config/qtile".source = ./config/qtile;
|
||||||
|
".config/nvim".source = ./config/nvim;
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
neovim
|
||||||
|
ripgrep
|
||||||
|
nil
|
||||||
|
nixpkgs-fmt
|
||||||
|
nodejs
|
||||||
|
gcc
|
||||||
|
rofi
|
||||||
|
xwallpaper
|
||||||
|
steam
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user