Code Monkey home page Code Monkey logo

kishikawakatsumi / sourcekitforsafari Goto Github PK

View Code? Open in Web Editor NEW
690.0 11.0 23.0 1.67 MB

SourceKit for Safari is a Safari extension for GitHub, that enables Xcode features like go to definition, find references, or documentation on hover.

Home Page: https://chrome.google.com/webstore/detail/sourcekit-for-chrome/ndfileljkldjnflefdckeiaedelndafe

License: MIT License

Objective-C 0.20% Swift 2.32% CSS 0.65% JavaScript 95.42% HTML 1.15% TypeScript 0.27%
sourcekit-lsp safari-extension chrome-extension

sourcekitforsafari's Introduction

SourceKit for Safari

SourceKit for Safari is a browser extension for GitHub, that enables IDE features on your browser such as symbol navigator, go to definition and documentation on hover.

Warning

This is really proof of concept code--functional proof of concept, but proof of concept nonetheless--and has not been thoroughly tested. Use at your own risk.

Features

Show Document Items

Bring up a list of document items, then select your desired document item to jump to the respective source code location.

Quick Help popup

Hovering the mouse cursor over a symbol shows documentation.

Jumps to Definition

If the text at the mouse cursor is a symbol defined in another file, turn it into a link navigating to the file.

Find References

Resolve project-wide references for the symbol denoted by the given text document position.

Highlights References

Highlights all references to the symbol scoped to this file.

Installation

Safari

  • Download the latest SourceKit for Safari.app from GitHub Releases, run it once to install the extension.
  • Open Safari - Preferences - Extension, make sure SourceKit for Safari is checked on the left panel.

Chrome

  • Download the latest SourceKit for Safari.app from GitHub Releases, run it once to install the helper app and the native messaging manifest.

  • Install the extension from Chrome Web Store

(From version 0.6.0, Native Messaging is used to communicate with Language Protocol Server. Therefore, no longer needed to keep the host application running. The extension will automatically launch the helper application. To install the helper application, launch SourceKit for Safari.app once. Then the helper application will be installed.)

(Unlike Safari Extension, Chrome Extension communicates with the language server through the host application. Therefore, the host application must be running while using the extension.)

Getting Started

SourceKit for Safari depends on SourceKit-LSP. In order to use SourceKit for Safari, you need to install SourceKit-LSP and set the installation location.

If you have installed Xcode 11.4+ or the corresponding Command Line Tools package, the SourceKit-LSP server is included and can be run with xcrun sourcekit-lsp.

If you are using a toolchain from Swift.org, the SourceKit-LSP server is included and can be run with xcrun --toolchain swift sourcekit-lsp.

If your toolchain did not come with SourceKit-LSP, you should build it from source.

SourceKit for Safari uses SourceKit-LSP that comes with Xcode 11.4 by default.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp

If you want to use other SourceKit-LSP binary, click the toolbar icon and set its full path to the settings text field.

(for Chrome users)

Hover over symbols in the source code; then, the documentation for that symbol a popup will show or turn it link to the definition (The first may take some time).

How it works

SourceKit for Safari will automatically clone a GitHub repository to your local filesystem (~/Library/Group Containers/$(TeamIdentifierPrefix).com.kishikawakatsumi.SourceKitForSafari) when you access there.

Then, when the source file is displayed on the browser, it automatically communicates with SourceKit-LSP to get information about the source code. Then show them with a popup on the browser.

SourceKit for Safari does not automatically update local repositories.

If the local repository is outdated, click the toolbar icon and press the Sync button to update it.

Troubleshooting

Chrome extension doesn't work

Make sure the host application (SourceKit for Safari.app) is running. Chrome extension requires the host application to communicate to the language server.

Development

To use Node Packaged Modules in injected scripts, it requires to combine multiple modules and JavaScript files into one JavaScript file using Browserify.

To do that, run the following commands in Terminal.app. (Node.js development environment such as npm command must be set up in advance.)

cd ./SafariExtension/js
npm install
npm run build

Please make sure to perform clean build when you change injected JavaScript or CSS files. Otherwise, the changes will not install correctly.

References

sourcekitforsafari's People

Contributors

dependabot[bot] avatar dmcrodrigues avatar johnno1962 avatar kishikawakatsumi avatar shinya-todaka avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sourcekitforsafari's Issues

macOS 10.14.6 can not open it

My System Operation version is 10.14.6 on iMac. so i can not open it.
Although I can update MacOS, I think you should Compatible with lower versions

[Feature] Add an option to opt-in to avoid useless cloning

Haven't tried to project yet (still waiting to download Xcode 11.4) but looks promising!

Reading the README I saw that the plugin would clone every GH repo you visit.

I think it would be nice to instead provide an opt-in option, so that it avoids cloning every single repo you visit – including the ones that you don't intend to navigate into (like if you quickly opened a link you saw on Twitter to a repo, to see what it's for but realise the project is not for you; of if you just went to a repo to read the README of a lib that you intend to use but never intend to work on and won't need GH navigation for it)

Can't get Chrome extension to work?

I've followed the instructions to the letter, but haven't been able to get it to work with Chrome, works fine for public repos on Safari. So the LSP server is running, and I have the helper application running, with the window visible and with the window closed. Would be great if the helper application was a menu bar app that could run in background and lunch on startup too.

Doesn't seem to work for private repos?

Haven't been able to get it to work with private repos, checked the ~/Library/Group Containers/27AEDK3C9F.com.kishikawakatsumi.SourceKitForSafari/ path and there is no cloned copy of the private repo. Can't see any logs either, so not sure where to look.

I'm using SSH authentication and [email protected]/repo URLs when cloning manually.

Submit to Chrome Web Store

Loading an unpacked extension is a less-than-ideal way to install them, because it breaks if you move the extension on-disk. Currently, you cannot even install manually packed extensions.

Please submit this to the Chrome Web Store so we can use it on Chrome :)

Doesn't seem to work with codes that have an available attribute?

I use version 0.6.2, the Symbol Navigator feature works, but Definition and Documentation are not displayed with the mouse hover.

I was randomly browsing Swift projects displayed in GitHub Explore, I found that the available attribute in the code doesn't work features except for Symbol Navigator.

Is this one of the possible causes?

Environment:

  • Version 0.6.2
  • Safari 13.1 (15609.1.20.111.8)
  • Xcode 11.4.1 (11E503a)
  • macOS Catalina 10.15.4 (19E287)

バージョン 0.6.2 を使っていて Symbol Navigator は動作するものの、Definition や Documentation がマウスホバーで表示されない問題がありました。

その後、GitHub Explore に表示された Swift のプロジェクトをランダムに閲覧していたところ、コード内に available アトリビュートが存在するもので Symbol Navigator 以外が動作しないということを発見しました。

これは原因の一つとして考えられるでしょうか?

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.