├── .gitignore ├── tsconfig.json ├── src └── index.ts ├── .github └── workflows │ └── release.yml ├── license ├── package.json └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | index.js 4 | pnpm-lock.yaml 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "compilerOptions": { 4 | "strict": true, 5 | "lib": ["esnext"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { ExtensionContext, LanguageClient, services } from "coc.nvim"; 2 | 3 | export async function activate(context: ExtensionContext): Promise { 4 | const languageClient = new LanguageClient( 5 | "solidity", 6 | "Solidity Language Server", 7 | { 8 | module: require.resolve("solidity-ls"), 9 | // module: require("path").join(__dirname, "..", "..", "solidity-ls"), 10 | // options: { execArgv: ["--inspect"] }, 11 | }, 12 | { 13 | documentSelector: ["solidity"], 14 | synchronize: { configurationSection: "solidity" }, 15 | } 16 | ); 17 | context.subscriptions.push(services.registLanguageClient(languageClient)); 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | release: 4 | types: [published] 5 | jobs: 6 | release: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - run: npm i esbuild --legacy-peer-deps 11 | - run: npm run build 12 | - uses: bruceadams/get-release@v1.2.3 13 | id: release 14 | env: 15 | GITHUB_TOKEN: ${{ github.token }} 16 | - uses: actions/setup-node@v2 17 | with: 18 | registry-url: "https://registry.npmjs.org" 19 | - run: npm version ${{ steps.release.outputs.tag_name }} --no-git-tag-version 20 | - run: npm publish 21 | env: 22 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 23 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 7c00 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coc-solidity", 3 | "description": "Solidity language server for coc.nvim", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/qiuxiang/coc-solidity" 7 | }, 8 | "keywords": [ 9 | "coc.nvim", 10 | "solidity" 11 | ], 12 | "files": [ 13 | "dist/index.js" 14 | ], 15 | "main": "dist/index.js", 16 | "scripts": { 17 | "build": "esbuild src/index.ts --platform=node --bundle --external:coc.nvim --external:solidity-ls --outdir=dist" 18 | }, 19 | "dependencies": { 20 | "solidity-ls": "^0.5.3" 21 | }, 22 | "devDependencies": { 23 | "coc.nvim": "0.0.83-next.9", 24 | "esbuild": "^0.18.17" 25 | }, 26 | "engines": { 27 | "coc": "^0.0.80" 28 | }, 29 | "activationEvents": [ 30 | "onLanguage:solidity" 31 | ], 32 | "contributes": { 33 | "rootPatterns": [ 34 | { 35 | "filetype": "solidity", 36 | "patterns": [ 37 | "package.json" 38 | ] 39 | } 40 | ], 41 | "configuration": { 42 | "type": "object", 43 | "title": "coc-solidity configuration", 44 | "properties": { 45 | "solidity.includePath": { 46 | "type": "string", 47 | "default": "node_modules", 48 | "description": "Make an additional source directory available to the default import callback. Use this option if you want to import contracts whose location is not fixed in relation to your main source tree, e.g. third-party libraries installed using a package manager. Can be used multiple times. Can only be used if base path has a non-empty value." 49 | }, 50 | "solidity.remapping": { 51 | "type": "object", 52 | "description": "Import remapping allows you to redirect imports to a different location in the virtual filesystem. The mechanism works by changing the translation between import paths and source unit names. For example you can set up a remapping so that any import from the virtual directory github.com/ethereum/dapp-bin/library/ would be seen as an import from dapp-bin/library/ instead." 53 | } 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | [npm]: https://www.npmjs.com/package/coc-solidity 2 | [npm-badge]: https://img.shields.io/npm/v/coc-solidity.svg 3 | 4 | # coc-solidity [![npm-badge]][npm] 5 | 6 | coc.nvim extension for solidity. Language server provided by [solidity-ls](https://github.com/qiuxiang/solidity-ls). 7 | 8 | imageimageimage 9 | 10 | This language server has no error tolerance. 11 | Means that some features will only work if sources are no syntax error. 12 | 13 | For example: 14 | 15 | ```solidity 16 | // should not work 17 | msg. 18 | ^ 19 | 20 | // should work 21 | msg.; 22 | ^ 23 | ``` 24 | 25 | # Features 26 | 27 | - completion 28 | -
29 | local variables, state variables, functions 30 | image 31 | image 32 |
33 | -
34 | contracts 35 | image 36 |
37 | -
38 | globally variables and it's members 39 | image 40 | image 41 |
42 | -
43 | struct members 44 | image 45 |
46 | -
47 | external contract functions 48 | image 49 |
50 | -
51 | diagnostics 52 | image 53 | image 54 |
55 | -
56 | hover documention 57 | image 58 | image 59 |
60 | -
61 | references 62 | image 63 |
64 | - formatting (by prettier-plugin-solidity) 65 | - rename 66 | - signature help (basic implementation) 67 | - go to references 68 | - go to definition 69 | 70 | ## Install 71 | 72 | `:CocInstall coc-solidity` 73 | 74 | Make sure you have installed [solc](https://github.com/ethereum/solidity/releases/latest). 75 | 76 | ### foundry supports 77 | 78 | run `forge remappings > remappings.txt` in project root. 79 | 80 | # Todo 81 | 82 | - [ ] code actions 83 | - [ ] semantic tokens 84 | --------------------------------------------------------------------------------