Giter Club home page Giter Club logo

vscode-kanata's Introduction

vscode-kanata

GitHub Repo stars Visual Studio Marketplace Installs GitHub Workflow Status (with event)

A VS Code extension that adds language support for kanata configuration files.

This extension aims to stay up-to-date with latest kanata git. Whenever something changes in parser folder in kanata repository, at the end of the day, Github Actions will automatically build a new version of this extension with updated parser.

Features

Kanata config files are detected by .kbd file extension.

Syntax highlighting

keywords, action identifiers, alias handles etc.

Checking for config errors

Config will be parsed and validated, when saving document.

Support for including other files

If you use include configuration items in your kanata config, make sure to adjust the following settings:

  • vscode-kanata.includesAndWorkspaces
  • vscode-kanata.mainConfigFile

Important: Absolute paths in include blocks that point outside the opened workspace aren't supported.

Also, if you work with multiple main files, and find yourself switching mainConfigFile often, there's a handy command palette entry:

  • Kanata: Set current file as main

Formatter: auto-apply spacial layout of defsrc to all deflayers

This is enabled by default, because I've seen a lot of kanata configs, and it seems like majority of users prefer to align their deflayers according to spacial layout of defsrc. If you have "Auto format on save enabled" and don't want this feature, you can disable it in settings (search for "kanata.format").

Goto definition

  • CTRL+Click on an identifier to go to definition
  • CTRL+Click on a definition to reveal references.

Implemented for aliases, variables, layers, virtualkeys, templates and includes. Supported in both single-mode and workspace (includes-enabled) mode.

Contributing

If you have an idea what could be improved, feel free to open an issue or a PR.

Bug reports

If you encounter a bug, please report it here: https://github.com/rszyma/vscode-kanata/issues

Building

See this document for build instructions.

Release notes

See the change log.

Credits

vscode-kanata's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar rszyma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vscode-kanata's Issues

Unknown key in defsrc while it is defined in deflocalkeys

VS Code version OS Extension version
1.82.3 Win 10 x64 pro (french) 22H2 v0.2.0

Steps to reproduce

  1. Check this config.
  2. save in VSCode

Results

[{
	"resource": "/D:/Programmes/Kanata/kanata.kbd",
	"owner": "Kanata Configuration Language",
	"severity": 8,
	"message": "Unknown key in defsrc: \"²\"",
	"source": "kanata-parser",
	"startLineNumber": 216,
	"startColumn": 3,
	"endLineNumber": 216,
	"endColumn": 4
}]

Expectations

When checking defsrc, it seems it doesn’t check in deflocalkeys-win if the key is defined.

formatter crash

panicked at src/formatter/use_defsrc_layout_on_deflayers.rs:252:34:
line comment inside deflayer should always have newline

this config causes crash:

(defsrc
  a b c
)
(deflayer base
  a b ;;
  c
)

while this doesn't:

(defsrc
  a b c
)
(deflayer base
  a b ;;
  c)

Enabling formatter results an error

If i enable formatter in settings, when trying to save I get this error:

recursive use of an object detected which would lead to unsafe aliasing in rust

[Error - 10:40:59 PM] Request textDocument/formatting failed.
  Message: Request textDocument/formatting failed with message: unreachable
  Code: -32603 
[Error - 10:41:00 PM] Notification handler 'textDocument/didSave' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
[Error - 10:41:00 PM] Request textDocument/formatting failed.
  Message: Request textDocument/formatting failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust
  Code: -32603 
[Error - 10:41:00 PM] Notification handler 'textDocument/didSave' failed with message: recursive use of an object detected which would lead to unsafe aliasing in rust

Bug: crash when including file that doesn't exist

panicked at src/formatter/defsrc_layout/get_layout.rs:67:22:
document should be cached

Stack:

Error
    at S.exports.__wbg_new_abda76e883ba8a5f (/home/n/.vscode/extensions/rszyma.vscode-kanata-0.9.25/out/server.js:34:2247)
    at wasm://wasm/004bdb72:wasm-function[1091]:0xd7f5c
    at wasm://wasm/004bdb72:wasm-function[508]:0xc41a4
    at wasm://wasm/004bdb72:wasm-function[763]:0xd3983
    at wasm://wasm/004bdb72:wasm-function[688]:0xcdffc
    at wasm://wasm/004bdb72:wasm-function[84]:0x6dfc7
    at as.onDocumentFormatting (/home/n/.vscode/extensions/rszyma.vscode-kanata-0.9.25/out/server.js:34:812)
    at /home/n/.vscode/extensions/rszyma.vscode-kanata-0.9.25/out/server.js:34:6367
    at /home/n/.vscode/extensions/rszyma.vscode-kanata-0.9.25/out/server.js:33:77865
    at ni (/home/n/.vscode/extensions/rszyma.vscode-kanata-0.9.25/out/server.js:3:9548)


[Error - 7:07:49 PM] Request textDocument/formatting failed.
  Message: Request textDocument/formatting failed with message: unreachable
  Code: -32603 

Steps to reproduce:

  1. Open in workspace mode (not sure it it's only in workspace)
  2. include file that doesn't exist.
  3. vscode-kanata crashes.

BUG: repeat declaration of key in defsrc

VS Code version OS Extension version
1.84.2 Win 10 x64 pro (french) 21H2 v0.3.0

Steps to reproduce

Try this config

(defcfg
	process-unmapped-keys yes
	log-layer-changes yes
)

(deflocalkeys-win
	lock 8
)

(defsrc
	lock
        7
)

(deflayer base
	_
        _
)

Results

It runs with no error in kanata but triggers the error in extension.

[{
	"resource": "/E:/OneDrive/Téléchargements/test.kbd",
	"owner": "Kanata Configuration Language",
	"severity": 8,
	"message": "Unknown key in defsrc: \"lock\"",
	"source": "kanata-parser",
	"startLineNumber": 11,
	"startColumn": 2,
	"endLineNumber": 11,
	"endColumn": 6
}]

I suspect the OSCode (base 10) is confused with scancode. In lock 8, 8 is the OSCode (base 10). The scancode for key 7 is 08.

With the key tester, 8 is for backspace and 55 is for key_7. It confirms there is no conflicts between the keys.
image

Bug: formatter not working when `template-expand` is used in `defsrc` or `deflayer`

e.g. this defsrc will stop any formatting because currently validity of defsrc is checked by counting number of items, without expanding accounting for expanded number of items after template-expand.

(defsrc
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps (template-expand home-row j)                            ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lmet lalt           spc            ralt rmet rctl
)

Similarly, template-expand will not format deflayers with template-expand for the same reason.

error reporting cmd is not enabled while it is

VS Code version OS Extension version
1.84.2 Win 10 x64 pro (french) 21H2 v0.4.0

Test this config

(defcfg
	process-unmapped-keys yes
	danger-enable-cmd yes
	log-layer-changes yes
)

(defsrc
	esc
)

(defalias
	esc (tap-hold 200 200 f (cmd cmd /k "echo test"))
)

(deflayer base
	@esc
)

It reports error line 12 cmd is not enabled but cmd action is specified somewhere.

Bug: LSP crashes when using `defaliasenvcond` in kanata config

I use your plugin to crate my configuration file but the LSP is not working. I have syntax highlighting but it doesn't show an error. The auto-detect defaultkeys are also not working, but I can choose them myself. For context, I have auto-save on in vscode. I use Windows 11. The file I am using is the default configure file in the Kanata docs repo because I was testing it.

Bug: Empty deflayer causes formatter crash

panicked at src/formatter/defsrc_layout/mod.rs:47:16:
attempt to subtract with overflow

Stack:

Error
    at /home/n/.vscode/extensions/rszyma.vscode-kanata-0.11.21/out/server.js:37:2918
    at X (/home/n/.vscode/extensions/rszyma.vscode-kanata-0.11.21/out/server.js:34:424)
    at S.exports.__wbg_new_abda76e883ba8a5f (/home/n/.vscode/extensions/rszyma.vscode-kanata-0.11.21/out/server.js:37:2899)
    at kls.wasm.console_error_panic_hook::Error::new::ha842e8090e6bbecd (wasm://wasm/kls.wasm-01bd220a:wasm-function[11743]:0x4e4ab6)
    at kls.wasm.console_error_panic_hook::hook_impl::h49cd7ab8835e94ec (wasm://wasm/kls.wasm-01bd220a:wasm-function[2663]:0x366209)
    at kls.wasm.console_error_panic_hook::hook::h1cdcb3fd683dbf05 (wasm://wasm/kls.wasm-01bd220a:wasm-function[14432]:0x50cfcd)
    at kls.wasm.core::ops::function::Fn::call::h63f1386438e14437 (wasm://wasm/kls.wasm-01bd220a:wasm-function[12283]:0x4ee0fb)
    at kls.wasm.std::panicking::rust_panic_with_hook::h32c80a64fe4de396 (wasm://wasm/kls.wasm-01bd220a:wasm-function[4928]:0x409d4c)
    at kls.wasm.std::panicking::begin_panic_handler::{{closure}}::hd496964d114e98b9 (wasm://wasm/kls.wasm-01bd220a:wasm-function[6788]:0x4602b5)
    at kls.wasm.std::sys_common::backtrace::__rust_end_short_backtrace::h0d4686a7fe3981a4 (wasm://wasm/kls.wasm-01bd220a:wasm-function[16251]:0x51df41)


[Error - 5:29:31 PM] Request textDocument/formatting failed.

Reproductible with config:

(deflayer )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.