docs: Update language

This commit is contained in:
~hedy
2025-01-05 09:10:59 +08:00
parent 12ec5f213c
commit 20aa0659e1
3 changed files with 12 additions and 10 deletions

View File

@@ -31,6 +31,9 @@
([#106](https://github.com/hedyhli/outline.nvim/pull/106)) ([#106](https://github.com/hedyhli/outline.nvim/pull/106))
- New provider for manpages - New provider for manpages
([#104](https://github.com/hedyhli/outline.nvim/pull/104)) ([#104](https://github.com/hedyhli/outline.nvim/pull/104))
- Give `symbols.icon_fetcher` a third parameter of type `outline.Symbol` to
access extra information from provider.
([#109](https://github.com/hedyhli/outline.nvim/pull/109))
### Fixes ### Fixes

View File

@@ -400,6 +400,7 @@ Pass a table to the setup call with your configuration options.
-- icon as string. -- icon as string.
---@param kind string Key of the icons table below ---@param kind string Key of the icons table below
---@param bufnr integer Code buffer ---@param bufnr integer Code buffer
---@param symbol outline.Symbol The current symbol object
---@returns string|boolean The icon string to display, such as "f", or `false` ---@returns string|boolean The icon string to display, such as "f", or `false`
--- to fallback to `icon_source`. --- to fallback to `icon_source`.
icon_fetcher = nil, icon_fetcher = nil,
@@ -910,29 +911,27 @@ symbols = {
} }
``` ```
The `icon_fetcher` function may also accept a second parameter, the buffer The `icon_fetcher` function may also accept a second and third parameter, the buffer
number of the code buffer. For example, you can use it to determine the icon number of the code buffer, and the symbol object of type `outline.Symbol`. For
to use based on the filetype. example, you can use it to determine the icon to use based on the filetype.
```lua ```lua
symbols = { symbols = {
icon_fetcher = function(kind, bufnr) icon_fetcher = function(kind, bufnr, symbol)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft') local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
-- ... -- ...
end, end,
} }
``` ```
The `icon_fetcher` function may also accept a third parameter, the symbol Or display public, protected, and private symbols differently:
which type is outline.Symbol. Provider can add extra info to symbol.
For example, access specifier information can be added at the icon location.
```lua ```lua
symbols = { symbols = {
icon_fetcher = function(kind, bufnr, symbol) icon_fetcher = function(kind, bufnr, symbol)
local access_icons = { public = '○', protected = '◉', private = '●' } local access_icons = { public = '○', protected = '◉', private = '●' }
local icon = require('outline.config').o.symbols.icons[kind].icon local icon = require('outline.config').o.symbols.icons[kind].icon
-- ctags provider add `access` key -- ctags provider might add an `access` key
if symbol and symbol.access then if symbol and symbol.access then
return icon .. ' ' .. access_icons[symbol.access] return icon .. ' ' .. access_icons[symbol.access]
end end
@@ -1099,7 +1098,7 @@ that simply returns in plain text, the first letter of the given kind.
```lua ```lua
symbols = { symbols = {
icon_fetcher = function(kind, bufnr) return kind:sub(1,1) end, icon_fetcher = function(kind, bufnr, symbol) return kind:sub(1,1) end,
} }
``` ```

View File

@@ -52,7 +52,7 @@ local lspkind = {
---@param kind string|integer ---@param kind string|integer
---@param bufnr integer ---@param bufnr integer
---@param symbol? outline.Symbol ---@param symbol outline.Symbol
---@return string icon ---@return string icon
function M.icon_from_kind(kind, bufnr, symbol) function M.icon_from_kind(kind, bufnr, symbol)
local kindstr = kind local kindstr = kind