Skip to content

Commit

Permalink
feat: update more recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Oct 27, 2023
1 parent d2a9a8c commit aa9a7b7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 65 deletions.
39 changes: 12 additions & 27 deletions src/content/docs/recipes/snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,23 @@ id: snippets
title: Custom Snippets
---

::::danger

UNVALIDATED: NEED UPDATING FOR V4

::::

`user/init.lua`:

Be sure to read the comments in order to understand how to use this code for your environment.
Here is an example plugin specification to go inside your plugins folder which adds a custom path for it to load from. Be sure to read the comments in order to understand how to use this code for your environment.

```lua
return {
plugins = {
{
"L3MON4D3/LuaSnip",
config = function(plugin, opts)
-- include the default astronvim config that calls the setup call
require "plugins.configs.luasnip"(plugin, opts)
-- load snippets paths
require("luasnip.loaders.from_vscode").lazy_load {
-- this can be used if your configuration lives in ~/.config/nvim
-- if your configuration lives in ~/.config/astronvim, the full path
-- must be specified in the next line
paths = { "./lua/user/snippets" }
}
end,
},
},
{
"L3MON4D3/LuaSnip",
config = function(plugin, opts)
-- include the default astronvim config that calls the setup call
require "plugins.configs.luasnip"(plugin, opts)
-- load snippets paths
require("luasnip.loaders.from_vscode").lazy_load {
paths = { vim.fn.stdpath "data" .. "/lua/snippets" }
}
end,
}
```

Depending on the location of your [configuration](/configuration/manage_user_config/), create a subdirectory named `snippets` under `lua/user`.
Depending on the location of your configuration (typically `~/.config/nvim`), create a subdirectory named `snippets` in your `lua/` folder.
Custom snippets will be added to this `snippets` directory. They will follow the vscode style as described in the [documentation](https://github.com/l3mon4d3/luasnip/blob/master/doc.md#vscode-snippets-loader)

This example Vue snippet is added as `snippets/vue.json`:
Expand Down
73 changes: 35 additions & 38 deletions src/content/docs/recipes/telescope_theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,45 @@ id: telescope_theme
title: NvChad Telescope Theme
---

::::danger

UNVALIDATED: NEED UPDATING FOR V4

::::

This code snippet makes the default theme telescope look like the default NvChad telescope theme:
This plugin specification makes the default theme telescope look like the default NvChad telescope theme:

![Screenshot of telescope theme](../../../assets/recipes/telescope_theme.png)

`user/init.lua`:

```lua
return {
highlights = {
-- set highlights for all themes
-- use a function override to let us use lua to retrieve colors from highlight group
-- there is no default table so we don't need to put a parameter for this function
init = function()
local get_hlgroup = require("astronvim.utils").get_hlgroup
-- get highlights from highlight groups
local normal = get_hlgroup "Normal"
local fg, bg = normal.fg, normal.bg
local bg_alt = get_hlgroup("Visual").bg
local green = get_hlgroup("String").fg
local red = get_hlgroup("Error").fg
-- return a table of highlights for telescope based on colors gotten from highlight groups
return {
TelescopeBorder = { fg = bg_alt, bg = bg },
TelescopeNormal = { bg = bg },
TelescopePreviewBorder = { fg = bg, bg = bg },
TelescopePreviewNormal = { bg = bg },
TelescopePreviewTitle = { fg = bg, bg = green },
TelescopePromptBorder = { fg = bg_alt, bg = bg_alt },
TelescopePromptNormal = { fg = fg, bg = bg_alt },
TelescopePromptPrefix = { fg = red, bg = bg_alt },
TelescopePromptTitle = { fg = bg, bg = red },
TelescopeResultsBorder = { fg = bg, bg = bg },
TelescopeResultsNormal = { bg = bg },
TelescopeResultsTitle = { fg = bg, bg = bg },
}
end,
{
"AstroNvim/astroui",
opts = {
highlights = {
-- set highlights for all themes
-- use a function override to let us use lua to retrieve
-- colors from highlight group there is no default table
-- so we don't need to put a parameter for this function
init = function()
local get_hlgroup = require("astrocore").get_hlgroup
-- get highlights from highlight groups
local normal = get_hlgroup "Normal"
local fg, bg = normal.fg, normal.bg
local bg_alt = get_hlgroup("Visual").bg
local green = get_hlgroup("String").fg
local red = get_hlgroup("Error").fg
-- return a table of highlights for telescope based on
-- colors gotten from highlight groups
return {
TelescopeBorder = { fg = bg_alt, bg = bg },
TelescopeNormal = { bg = bg },
TelescopePreviewBorder = { fg = bg, bg = bg },
TelescopePreviewNormal = { bg = bg },
TelescopePreviewTitle = { fg = bg, bg = green },
TelescopePromptBorder = { fg = bg_alt, bg = bg_alt },
TelescopePromptNormal = { fg = fg, bg = bg_alt },
TelescopePromptPrefix = { fg = red, bg = bg_alt },
TelescopePromptTitle = { fg = bg, bg = red },
TelescopeResultsBorder = { fg = bg, bg = bg },
TelescopeResultsNormal = { bg = bg },
TelescopeResultsTitle = { fg = bg, bg = bg },
}
end,
},
},
}
```

0 comments on commit aa9a7b7

Please sign in to comment.