bkmr-lsp
Language Server Protocol (LSP) implementation for bkmr snippet management.
Overview
bkmr-lsp provides code completion for bkmr snippets in any LSP-compatible editor. Snippets are automatically interpolated, delivering processed content rather than raw templates.
Requirements
- bkmr: Version 4.24.0 or later
- LSP Client: Any LSP-compatible editor (VS Code, Vim/Neovim, Emacs, etc.)
Installation
From Source
Prerequisites
Ensure bkmr (>= 4.24.0) is installed and contains snippets:
# Install bkmr if not present
# Verify version
# Add test snippet
Configuration
VS Code
Install an LSP extension and add to settings.json:
Vim/Neovim with vim-lsp
if executable('bkmr-lsp')
augroup LspBkmr
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'bkmr-lsp',
\ 'cmd': {server_info->['bkmr-lsp']},
\ 'allowlist': ['*'],
\ })
augroup END
endif
Neovim with nvim-lspconfig
require..
Emacs with lsp-mode
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration '(".*" . "text"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "bkmr-lsp")
:major-modes '(text-mode)
:server-id 'bkmr-lsp)))
Usage
Code Completion
Start typing in any file and trigger completion:
- VS Code:
Ctrl+Space - Vim:
Ctrl+X Ctrl+OorCtrl+N - Neovim: Automatic with completion plugins
- Emacs:
M-x completion-at-point
Template Interpolation
Snippets with templates are automatically processed:
# Snippet content: {{ "pwd" | shell }}
# Completion inserts: /Users/username/project
Filtering
Use prefixes to filter completions:
- Type
jsto show JavaScript snippets - Type
pyto show Python snippets - Type partial titles to narrow results
Commands
The LSP server supports these commands:
bkmr.refresh: Refresh snippet cache (no-op, snippets are fetched live)bkmr.open: Open snippet by ID
Troubleshooting
No Completions Appearing
- Verify bkmr works:
bkmr search -t _snip_ - Check bkmr version:
bkmr --version - Test LSP server:
echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{}}' | bkmr-lsp
Raw Templates in Completions
Update bkmr to version 4.24.0 or later:
LSP Server Not Starting
- Verify binary is in PATH:
which bkmr-lsp - Check editor LSP configuration
- Review editor LSP logs for errors
Development
Building
Testing
Logging
Set RUST_LOG=debug for detailed logging:
RUST_LOG=debug
Protocol Support
- LSP Version: 3.17
- Features:
- Text document completion
- Command execution
- Workspace commands
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
Related Projects
- bkmr - Command-line bookmark and snippet manager
- vim-bkmr-lsp - Vim plugin for bkmr-lsp