Skip to content

Commit

Permalink
Merge pull request #4 from MrcJkb/1-add-optional-keybinding-to-search…
Browse files Browse the repository at this point in the history
…-for-word-under-cursor

feat: add option to search for word under cursor
  • Loading branch information
mrcjkb authored Oct 19, 2022
2 parents 1d3d8e6 + 0df3886 commit 9f91408
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.0] - 2022-10-19
### Added
- Add option to search for word under cursor

## [0.2.0] - 2022-10-19
### Added
- Attach `nix` highlighter to previewer
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
A [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) extension for [Manix](https://github.com/mlvzk/manix)
> A fast documentation searcher for [Nix](https://nixos.wiki/wiki/Overview_of_the_Nix_Language)
## Quick links
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Customisation](#customisation)

## Features

#### Nix fuzzy search
[![asciicast](https://asciinema.org/a/t1rHXoElZtqW9lIhOamNG2xgu.svg)](https://asciinema.org/a/t1rHXoElZtqW9lIhOamNG2xgu)

#### Search for the word under the cursor
[![asciicast](https://asciinema.org/a/6FyS0Bkp7bqSYLvY4OwvxzOF7.svg)](https://asciinema.org/a/6FyS0Bkp7bqSYLvY4OwvxzOF7)

## Prerequisites

* Depends on [Manix](https://github.com/mlvzk/manix).
Expand Down Expand Up @@ -47,10 +61,6 @@ telescope.load_extension('manix')

```lua
require('telescope-manix').search()

-- or

require('telescope').extensions.manix.search()
```

## Customisation
Expand All @@ -59,6 +69,8 @@ require('telescope').extensions.manix.search()
default_opts = {
-- CLI arguments to pass to manix, see `manix --help`
manix_args = {},
-- Set to true to search for the word under the cursor
cword = false,
}
require('telescope-manix').search(default_opts)
```
3 changes: 2 additions & 1 deletion lua/telescope-manix/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ end
local M = {}

local function mk_manix_cmd(opts)
local search_arg = opts.cword and vim.fn.expand "<cword>" or ""
local args = opts.manix_args or {}
return vim.tbl_flatten { 'manix', "", args, }
return vim.tbl_flatten { 'manix', search_arg, args, }
end

local function merge(...)
Expand Down

0 comments on commit 9f91408

Please sign in to comment.