diff --git a/.gitignore b/.gitignore index defd41a..d9da416 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,14 @@ **.after/ **.vscode/ +**.down/ +**/*.down ./lib/ -./down-lsp -./down +down-lsp +down +down-lsp.sh +downls **.DS_Store +**.lapce/ **.idea/ **node_modules **ext/c diff --git a/.luacheckrc b/.luacheckrc index c9db271..ed494ad 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,14 +1,15 @@ +-- std = "lua51+nvim" + cache = true codes = true self = false - read_globals = { "vim", } -- Global objects globals = { "_", - "word", + "down", "vim", "log", } diff --git a/.luarc.json b/.luarc.json index 3ff1a4e..4be34bd 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,6 +1,12 @@ { "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", "workspace.checkThirdParty": false, + "runtime.version": "LuaJIT", + "workspace.library": [ + "$VIMRUNTIME", + "lua", + "${3rd]/luv/library" + ], "semantic.annotation": true, "semantic.keyword": true, "semantic.variable": true, diff --git a/Justfile b/Justfile index 6d62698..c490903 100644 --- a/Justfile +++ b/Justfile @@ -2,10 +2,22 @@ # # nvimf="--headless -u ./test/config/minit.lua --noplugin -c ''" +lint: + @printf "\nLuacheck\n" + luacheck --config .luacheckrc ./lua ./test + @printf "\nSelene\n" + selene --display-style=quiet lua/* test/* + @printf "\nStylua\n" + stylua --check . + w: ./scripts/bin/down + wl: - ./scripts/bin/downls + ./scripts/bin/down-lsp + +wsl: + ./scripts/bin/down-lsp.sh lnw: rm -rf ./down @@ -13,13 +25,18 @@ lnw: lnwl: rm -rf ./down-lsp ln -s ./scripts/bin/down-lsp ./down-lsp +lnwls: + rm -rf ./down-lsp.sh + ln -s ./scripts/bin/down-lsp.sh ./down-lsp.sh iw: lnw cp -r ./scripts/bin/down ${HOME}/.local/bin/ iwl: lnwl cp -r ./scripts/bin/down-lsp ${HOME}/.local/bin/ +iwls: lnwls + cp -r ./scripts/bin/down-lsp.sh ${HOME}/.local/bin/ -i: iw iwl +i: iw iwl iwls clean: fd --no-ignore --glob "*-E" -x "rm" ./ @@ -28,6 +45,7 @@ v: nvim -u ./test/config/minit.lua # -c 'Lazy install' + # books: # cd book && mdbook serve diff --git a/assets/helix/languages.toml b/assets/helix/languages.toml new file mode 100644 index 0000000..8f089db --- /dev/null +++ b/assets/helix/languages.toml @@ -0,0 +1,102 @@ +[language-server.down] +command = "down-lsp.sh" +args = ["--stdio"] +timeout = 20 + +[language-server.down.config] +documentFormatting = true + +[language-server.down.config.workspaces] +default = "~/home", +notes = "~/notes", +wiki = "~/wiki" +index = "index", +notes = "notes", + +[language-server.down.config.down] +rootMarkers = [".git/"], +filetypes = ["down"] +debug = false + +[language-server.down.environment] +DOWN_LSP_PATH = "$HOME/.local/bin/down-lsp.sh" +DOWN_BIN_PATH = "$HOME/.local/bin/down.sh" + +[[language]] +name = "markdown" +language-servers = [ + { + name = "down", + only-features = [ + "hover", + "completion", + "workspace-command", + "workspace-symbols", + "goto-reference", + "rename-symbol", + "document-symbols", + "diagnostics", + "goto-definition", + "signature-help", + "code-action", + "inlay-hint", + "document-highlight", + "format", + "goto-declaration", + "goto-implementation", + "goto-type-definition", + ] + } +] + +[[language]] +name = "down" +language-id = "down" +shebangs = ["down", "down-lsp", "dwn"] +auto-format = true +file-types = ["down", "dw"] +comment-tokens = ["--", "-!"] +roots = [ + ".git/", ".down/", ".downrc", ".downignore", "*.down" +] +text-width = 100 +block-comment-tokens = [ + { start = "-/", end = "/-"} + { start = "--!", end = "!--"} +] +scope = "source.down" +soft-wrap = true +workspace-lsp-root +indent = { tab-width = 2, unit = " " } +language-servers = [ + { + name = "down", + only-features = [ + "hover", + "completion", + "workspace-command", + "workspace-symbols", + "goto-reference", + "rename-symbol", + "document-symbols", + "diagnostics", + "goto-definition", + "signature-help", + "code-action", + "inlay-hint", + "document-highlight", + "format", + "goto-declaration", + "goto-implementation", + "goto-type-definition", + ] + } +] + +[[grammar]] +name = "down" +file-types = ["down", "dw"] +comment-tokens = ["--", "-/", "/-", "-!"] +scope = "source.down" +indent = { tab-width = 2, style = "space" } +language-servers diff --git a/assets/shell/nu/down.nu b/assets/shell/nu/down.nu new file mode 100644 index 0000000..e69de29 diff --git a/assets/shell/zsh/down.zsh b/assets/shell/zsh/down.zsh new file mode 100644 index 0000000..e69de29 diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index ca1067c..ab34249 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -5,7 +5,7 @@ Welcome -- to the `down.lua` book. I hope this helps! - [Intro](./intro.md) - [About](./about/index.md) - - [Philosophy](./philosophy.md) + - [Philosophy](./about/philosophy.md) - [Compare](./about/compare.md) - [Configuring](./config/index.md) diff --git a/book/src/about/philosophy.md b/book/src/about/philosophy.md index a681198..7fc0d49 100644 --- a/book/src/about/philosophy.md +++ b/book/src/about/philosophy.md @@ -1 +1,5 @@ # Philosophy + +## Why? + +I started `down.lua` primarily due to my conflicting captivation and frustration with existing solutions like [org-mode](#) and, more recently in the burgeoning `Neovim` ecosystem, [neorg](https://github.com/nvim-neorg/neorg). diff --git a/ext/dlsp/.cargo/config.toml b/ext/dlsp/.cargo/config.toml deleted file mode 100644 index e6a7662..0000000 --- a/ext/dlsp/.cargo/config.toml +++ /dev/null @@ -1,20 +0,0 @@ -[alias] -b = "build" -r = "run" -t = "test" -c = "check" -R = "run --release" -rx = "R --example --recursions" -sx = ["run", "--release", "--", "\"command_list\""] - -[env] -WORD_LSP_NAME = "wordlsp" -PATH = "$PATH" -CACHE = "$HOME/.cache/$WORD_LSP_NAME" -TEMPD = "$HOME/.tm/$WORD_LSP_NAME" -DATAD = "$HOME/.local/share/$WORD_LSP_NAME" -STATE = "$HOME/.local/state/$WORD_LSP_NAME" -CONFD = "$HOME/.config/$WORD_LSP_NAME" - -[cargo-new] -vcs = "git" diff --git a/ext/dlsp/Cargo.toml b/ext/dlsp/Cargo.toml deleted file mode 100644 index 2dfdba8..0000000 --- a/ext/dlsp/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[workspace] -resolver = "2" -members = ['./lib/client', "./lib/serve"] -exclude = [] - -[workspace.package] -name = "down-lsp" -version = "0.1.0" -license = "MIT" -license-file = "./LICNESE" -readme = "./README.md" -authors = [ - "Chris Pecunies " -] -edition = "2021" - -[workspace.metadata] - - -[workspace.dependencies] -tokio = { version = "1.42.0", features = ["full"] } -tower-lsp = { version = "0.20.0", features = ["tokio", "tokio-util"] } -tower = { version = "0.5.1", features = ["full"] } -tokio-util = { version = "0.7.12", features = ["full"] } diff --git a/ext/dlsp/LICENSE b/ext/dlsp/LICENSE deleted file mode 100644 index 16a5d4d..0000000 --- a/ext/dlsp/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Chris Pecunies - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ext/dlsp/README.md b/ext/dlsp/README.md deleted file mode 100644 index d1e3dd1..0000000 --- a/ext/dlsp/README.md +++ /dev/null @@ -1,309 +0,0 @@ -# down.lua - -the _familiar_, organized future for neovim and beyond! - - ![Neovim](https://img.shields.io/badge/Neovim%200.10+-brightgreen?style=for-the-badge) - ![License](https://img.shields.io/badge/license-GPL%20v3-brightgreen?style=for-the-badge) -![LuaRocks](https://img.shields.io/luarocks/v/clpi/down.lua) - ---- - -> [!Caution] -> -> `down.lua` is currently in **early** *ongoing* development. - - - -- [down - the _familiar_, organized future for neovim](#down-the-familiar-organized-future-for-neovim) - - [Introduction](#introduction) - - [Requirements](#requirements) - - [Quickstart](#quickstart) - - [Config](#config) - - [Usage](#usage) - - [Todo](#todo) - - [Support](#support) - - [Credits](#credits) - - -## Introduction - -- `down.lua` is a [neovim](#) plugin intended to bring the extensibility of [org-mode](#) or [neorg](github.com/nvim-neorg/neorg) with the **comfort** of [markdown](#). - -- In its [current state](#), `down.lua` is in the beginning stages of development, currently functionining as a markdown-based version of [neorg](#), with many planned features to come - -- we want to be able to take notes like developers, without leaving behind all the ecosystem benefits of markdown. - -- it's a work in progress and will be updated regularly - -## Requirements - -> [!Note] -> -> `down.lua` must have at least [neovim 0.10+](https://neovim.io) - -## Quickstart - -
- -lazy.nvim - - -```lua --- Place in lazy.nvim spec -{ - "clpi/down.lua", - version = "*", - lazy = false, - branch = "master", - config = function() - require "down".setup { - mod = { - workspace = { - config = { - default = "notes", - workspaces = { - default = "~/down", - notes = "~/notes", - personal = "~/home" - } - } - } - } - } - end, - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - "pysan3/pathlib.nvim", - "nvim-telescope/telescope.nvim", -- optional - }, -} -``` - -
- ---- - -
- - -plug.vim - - -> [!Caution] -> -> Not yet tested - -```vim -Plug "nvim-telescope/telescope.nvim" -Plug "nvim-treesitter/treesitter.nvim" -Plug "nvim-lua/plenary.nvim", -Plug "MunifTanjim/nui.nvim", -Plug "pysan3/pathlib.nvim" -Plug "clpi/down.lua", { - \ "branch" : "master", - \ "do" : ':lua require([[down]]).setup({ - \ mod = { - \ workspace = { - \ config = { - \ workspaces = { - \ wiki = [[~/wiki]], - \ default = [[~/down]], - \ notes = [[~/notes]] - \ } - \ } - \ } - \ } - \ })' - \ } -``` - -
- ---- - -
-Vundle - -> [!Caution] -> -> Not yet tested - -```vim -Plugin "pysan3/pathlib.nvim" -Plugin 'nvim-telescope/telescope.nvim' -Plugin "nvim-lua/plenary.nvim", -Plugin "MunifTanjim/nui.nvim", -Plugin 'clpi/down.lua' -``` - -
- ---- - -
- - -dein.vim - - -> [!Caution] -> -> Not yet tested - -```vim -call dein#add("nvim-lua/plenary.nvim") -call dein#add("MunifTanjim/nui.nvim") -call dein#add('pysan3/pathlib.nvim') -call dein#add('nvim-telescope/telescope.nvim') -call dein#add('clpi/down.lua') -``` - -
- ---- - -
- - -packer.nvim - - -> [!Caution] -> -> Not yet tested - -```lua -use { - "clp/down.lua", - requires = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - "pysan3/pathlib.nvim" - }, - tag = "*", - branch = 'master', - config = function() - require("down").setup({ - mod = { - workspace = { - config = { - workspaces = { - default = "~/down", - home = "~/notes", - notes = "~/notes" - } - } - } - } - }) - end, -} -``` - -
- ---- - -
- - -mini.deps - - -> [!Caution] -> -> Not yet tested - -```lua -{ - "clp/down.lua", -} -``` - -
- ---- - -
- - -rocks.nvim - - -> [!Caution] -> -> Not yet tested - -``` -:Rocks install mini.lua -``` - -
- -## Config - -```lua --- Setup the initial config --- with workspace 'home' at ~/home --- and make it default -require("down").setup({ ---@type down.mod.Config - mod = { - workspace = { - config = { - default = 'home', - workspaces = { - default = "~/down", - home = "~/notes", - notes = "~/notes" - } - } - } - } -}) -``` - -## Usage - -### Modules - -- `config` - configuration settings - -### Default Modules - -`...` - -## Todo - -> [!Tip] -> -> Check out [TODO.md](./TODO.md) for a more detailed list of tasks - -## Contributing - -> [!Tip] -> -> Check out [CONTRIBUTING.md](./CONTRIBUTING.md) for a more detailed overview of how to contribute - -## Credits - -`down.lua` is a project by [clpi](github.com/clpi) and is licensed under the [MIT](./LICENSE) license. For information about **contributing**, please consult the [CONTRIBUTING.md](./CONTRIBUTING.md) file. - -special thanks goes to [nvim-neorg/neorg](https://github.com/nvim-neorg/neorg) for providing the inspiration and basis of this project. - ---- - -thank you and keep updated! - -- [The `down.lua` book](https://down.cli.st) -- [The `down.lua` wiki](https://github.com/clpi/down.lua/wiki) -- [`down.lua` on luarocks](https://luarocks.org/inits/clpi/down.lua) -- [`down.lua` on dotfyle](https://dotfyle.com/plugins/clpi/down.lua) - - -

(back to top)

- - - diff --git a/ext/dlsp/lib/client/Cargo.toml b/ext/dlsp/lib/client/Cargo.toml deleted file mode 100644 index 87c8051..0000000 --- a/ext/dlsp/lib/client/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "client" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/ext/dlsp/lib/client/src/lib.rs b/ext/dlsp/lib/client/src/lib.rs deleted file mode 100644 index b93cf3f..0000000 --- a/ext/dlsp/lib/client/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/ext/dlsp/lib/serve/Cargo.toml b/ext/dlsp/lib/serve/Cargo.toml deleted file mode 100644 index 0d30e39..0000000 --- a/ext/dlsp/lib/serve/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "serve" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/ext/dlsp/lib/serve/src/lib.rs b/ext/dlsp/lib/serve/src/lib.rs deleted file mode 100644 index b93cf3f..0000000 --- a/ext/dlsp/lib/serve/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/ext/dlsp/src/lib.rs b/ext/dlsp/src/lib.rs deleted file mode 100644 index b93cf3f..0000000 --- a/ext/dlsp/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/lua/down/lsp/client/init.lua b/lua/down/lsp/client/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/down/lsp/completion/init.lua b/lua/down/lsp/completion/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/down/lsp/core/init.lua b/lua/down/lsp/core/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/down/lsp/document/init.lua b/lua/down/lsp/document/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/down/lsp/init.lua b/lua/down/lsp/init.lua new file mode 100644 index 0000000..7a281a4 --- /dev/null +++ b/lua/down/lsp/init.lua @@ -0,0 +1,166 @@ +local Lsp = {} + +Lsp.attributes = { + +} + +Lsp.capabilities = { + textDocumentSync = { + save = { + includeText = false + } + }, + definitionProvider = true, + hoverProvider = true, + workspace = { + workspaceFolders = { + supported = true, + changeNotifications = true + }, + fileOperations = { + didRename = { + filters = function() + local filters = {} + return filters + end, + } + } + }, + typeDefinitionProvider = true, + implementationProvider = true, + referencesProvider = true, + workspaceSymbolProvider = true, + codeLensProvider = { + resolveProvider = true + }, + executeCommandProvider = { + commands = { + "down.rename", + "down.note.new", + "down.workspace.change", + "down.workspace.new", + "down.workspace.delete", + "down.file.remove", + "down.file.new" + } + }, + codeActionProvider = { + codeActionKinds = { + '', 'quickfix', + 'refactor.rewrite', + 'refactor.extract', + }, + resolveProvider = false + }, + diagnosticProvider = { + identifier = "down", + interFileDependencies = true, + workspaceDiagnostics = true, + }, + inlayHintProvider = { + resolveProvider = true + }, + documentSymbolProvider = true, + documentRangeFormattingProvider = true, + foldingRangeProvider = true, + +} +Lsp.info = { + serverInfo = { name = "down", version = "0.1.2-alpha" }, + capabilities = Lsp.capabilities +} + +Lsp.register = function(method) + return function(attr) + Lsp.attributes[method] = attr + end +end + +Lsp.register "initialize" { + function(params) + if params.rootUri then + + end + if params.workspaceFolders then + + end + print "Server init" + return Lsp.info + end +} + +Lsp.register "initialized" { + ---@async + function(params) + local _ = {} + local registrations = {} + print "Server initialized" + return true + end +} + +Lsp.register "exit" { + function() + print "Server exit" + os.exit(0, true) + end +} + +Lsp.register "shutdown" { + function() + print "Server shutdown" + return true + end +} +Lsp.register "workspace/didChangeConfiguration" { + ---@async + function(params) + + end +} +Lsp.register "textDocument/completion" { + ---@async + function(params) + end +} +Lsp.register "completionItem/resolve" { + ---@async + function(params) + end +} +Lsp.register "textDocument/codeAction" { + ---@async + function(params) + end +} +Lsp.register "textDocument/codeLens" { + ---@async + function(params) + local lenses = {} + return lenses + end +} +Lsp.register "workspace/executeCommand" { + ---@async + function(params) + + end +} +Lsp.register "codeLens/resolve" { + ---@async + function(params) + end +} +Lsp.register "textDocument/inlayHint" { + ---@async + function(params) + local hints = {} + return hints + end +} +Lsp.register "inlayHint/resolve" { + ---@async + function(params) + end +} +return Lsp diff --git a/lua/down/lsp/main.lua b/lua/down/lsp/main.lua new file mode 100644 index 0000000..b57b623 --- /dev/null +++ b/lua/down/lsp/main.lua @@ -0,0 +1,19 @@ +#!/usr/bin/env lua + +Lsp = require "./init" +Work = require "./workspace/init" +Doc = require "./document/init" + +function main() + Work.init() + local a, ac = arg, #arg + + for i, ar in pairs(a) do + print(i, ar) + end + print("\x1b[33mRunning...\x1b[0m") +end + +main() + +--vim:ft=lua diff --git a/lua/down/lsp/notebook/init.lua b/lua/down/lsp/notebook/init.lua new file mode 100644 index 0000000..7e58986 --- /dev/null +++ b/lua/down/lsp/notebook/init.lua @@ -0,0 +1,2 @@ +local N = {} +return N \ No newline at end of file diff --git a/lua/down/lsp/service/init.lua b/lua/down/lsp/service/init.lua new file mode 100644 index 0000000..c1fb52d --- /dev/null +++ b/lua/down/lsp/service/init.lua @@ -0,0 +1,33 @@ +local e = require "/nix/store/6qk1rdc2lnk8yc6bvnnda70crcx5jysp-luarocks_bootstrap-3.11.1/lib/luarocks/rocks-5.2/luasocket/3.1.0-1" +local e = require "/nix/store/6qk1rdc2lnk8yc6bvnnda70crcx5jysp-luarocks_bootstrap-3.11.1/lib/lua/5.2" +e +local S = {} + +S.send = function() + print("Sending message") +end + +S.start = function() + print("Server started") +end + +S.req = function(name, params, cb) + local id = l + local m = { + id = 1, + method = name, + params = params, + } + print("Request received") +end +S.listen = function() + print("Listening") +end +S.reply = function() + local m = { + id = 1, + result = "ok", + } +end + +return S diff --git a/lua/down/lsp/util/init.lua b/lua/down/lsp/util/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/down/lsp/util/json.lua b/lua/down/lsp/util/json.lua new file mode 100644 index 0000000..7cd22c1 --- /dev/null +++ b/lua/down/lsp/util/json.lua @@ -0,0 +1,8 @@ +local J = {} + +module("down.lsp.util.json") + +J.rpc = function() + +end +return J diff --git a/lua/down/lsp/workspace/init.lua b/lua/down/lsp/workspace/init.lua new file mode 100644 index 0000000..dabf474 --- /dev/null +++ b/lua/down/lsp/workspace/init.lua @@ -0,0 +1,7 @@ +local W = {} + +function W.init() + print("W.init") +end + +return W diff --git a/lua/down/mod/tool/trouble/util.lua b/lua/down/mod/tool/trouble/util.lua index c3c1750..48a9b71 100644 --- a/lua/down/mod/tool/trouble/util.lua +++ b/lua/down/mod/tool/trouble/util.lua @@ -5,7 +5,9 @@ local M = mod.create("tool.trouble") local tro_ok, tro = pcall(require, "trouble") ---@return -function M.has_trouble() - if tro_ok then return tro - else return nil -end +-- function M.has_trouble() +-- if tro_ok then return tro +-- else return nil +-- end + +return M \ No newline at end of file diff --git a/scripts/bin/down-lsp.sh b/scripts/bin/down-lsp.sh index 4580357..88bf19a 100755 --- a/scripts/bin/down-lsp.sh +++ b/scripts/bin/down-lsp.sh @@ -43,17 +43,17 @@ # | | # # +----------------------------------------------------+ # -export down_LSP_BIN="down-lsp" -export down_LSP_COMPLETIONS=$(head >/tmp/downls.log + echo -e "$resp" +} + +lsp-completions() { + echo '' +} + +lsp-notify() { + lsp-encode '{ + "method": "'"$1"'", + "params": '"$2"' + }' +} +lsp-reply() { + lsp-encode '{ + "jsonrpc": "2.0", + "id": '"$1"', + "result": '"$2"' + }' +} +lsp-req() { + lsp-encode '{ + "jsonrpc": "2.0", + "id": '"$1"', + "method": "'"$2"'", + "params": '"$3"' + }' +} +lsp-initialize() { + lsp-req "$1" "initialize" '{ + "rootPath": "/Users/clp/clp", + "workspaceFolders": [ + { + "uri": "file:///Users/clp/clp", + "name": "clp" + } + ], + }' +} + +lsp-handle() { + local id="$1" + case $2 in + 'initialize') lsp-reply id '{ + "serverInfo": { + "name": "downls", + "version": "0.1.2-alpha" + }, + "capabilities": { + "completionProvider": { + + }, + "hoverProvider": true, + "definitionProvider": true, + "workspaceSymbolProvider": true, + "workspace": { + "workspaceFolders": { + "supported": true, + "changeNotifications": true + } + }, + "textDocumentSync": 1 + } + }' ;; + 'workspace/configuration') lsp-reply id '{ + }' ;; + 'textDocument/completion') lsp-reply id '{ + "isIncomplete": false, + "items": '"$CMP"' + }' ;; + 'textDocument/codeAction') lsp-reply id '{ + }' ;; + 'textDocument/codeLens') lsp-reply id '{ + }' ;; + 'textDocument/definition') lsp-reply id '{ + }' ;; + 'textDocument/documentHighlight') lsp-reply id '{ + }' ;; + 'textDocument/documentSymbol') lsp-reply id '{ + }' ;; + 'textDocument/formatting') lsp-reply id '{ + }' ;; + 'shutdown') lsp-reply id 'null' ;; + 'exit') exit ;; + *) ;; + esac +} + +main() { + echo -e 'Starting lsp server' + while IFS= read -r line; do + [[ "$line" =~ ^Content-Length:\ ([0-9]+) ]] + len="${BASH_REMATCH[1]}" + len=$((len + 2)) + payload=$(head -c "$len") + echo -e "$payload $len $line" + id=$(echo -E "$payload" | jq -r '.id') + mt=$(echo -E "$payload" | jq -r '.method') + lsp-handle "$id" "$mt" + done +} + +main "$@" +#vim:ft=bash diff --git a/scripts/gen b/scripts/gen deleted file mode 100755 index 0682a1b..0000000 --- a/scripts/gen +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env codon run - -import os -import sys - -os.system("echo 'hi there") - -# vim:ft=python diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 0000000..d16b99d --- /dev/null +++ b/scripts/lint @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +check() { + echo -e "Check" + luacheck --config .luacheckrc lua/ test/ +} +sele() { + echo -e "Selene" + selene --display-style=quiet lua/* test/* +} +styl() { + echo -e "Stylua" + stylua --config stylua.toml lua/ test/ +} + +main() { + [[ -z $1 ]] && check && styl && sele + [[ $1 == "check" ]] && check + [[ $1 == "sele" ]] && sele + [[ $1 == "styl" ]] && styl +} + +main "$@" + +#vim:ft=bash diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..83ab4e8 --- /dev/null +++ b/selene.toml @@ -0,0 +1,7 @@ +std = "neovim" + +[rules] +global_usage = "follow" +mixed_table = "allow" +multiple_statements = "allow" +incorrect_standard_library_use = "allow" diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..22d6d3e --- /dev/null +++ b/stylua.toml @@ -0,0 +1,6 @@ +column_width = 100 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferSingle" +call_parentheses = "Input"