欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  新闻

常用的sublime自动补全插件(sublimetext3自动补全代码)

程序员文章站 2024-03-29 11:52:58
安装homebrew/usr/bin/ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/i...

安装homebrew

/usr/bin/ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/install)"

bash

通过brew cask安装sublime text

brew cask install sublime-text

bash

安装package control

在launchpad中打开sublime text,按下control(ctrl)键+`或者view > show console中打开控制台,输入以下内容

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'package control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.proxyhandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

如果是sublime text2输入下面的内容

import urllib2,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'package control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else none; urllib2.install_opener( urllib2.build_opener( urllib2.proxyhandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else none; print('error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'please restart sublime text to finish installation')

安装codecs33与converttoutf8

使sublime text支持utf-8编码
找到tool->command palette,输入install package,选择第一个,回车,搜索codecs33与converttoutf8,因为网络原因,可能需要等待一小会,可以在最底下的状态栏查看是否完成。

安装clang-complete

一款c/c++插件,支持补全、保存时检查错误,同上一步,搜索clang-complete并安装。
配置,因为这款插件有点老,自带的配置文件对应的头文件库文件很大一部分是不存在的,导致功能异常,需要自己改配置文件,
来到/users/用户名/library/application support/sublime text 3/packages/clang-complete目录,可以在sublime text->preferences->browse packages…找到这个目录。
打开cc.sublime-settings文件
找到大概34行左右,将include_options修改为下面的内容,可能需要提前安装好xcode,如果路径不对,可自行修改。

 "include_options":
[
"-isystem", "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/lib/clang/8.0.0/include",
"-isystem", "/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx.sdk/usr/include/",
"-isystem", "/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx.sdk/usr/include/c++/4.2.1",
"-f/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx.sdk/system/library/frameworks/",
"-isystem", "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/include/c++/v1",
"-isystem", "/usr/include",
"-isystem", "/usr/include/c++/*",
"-isystem", "/usr/local/include",
"-isystem", "/usr/local/include/c++/*",
//"-isystem", "/usr/local/opt/llvm/include",
"-wall"
],

配置lua环境

#安装lua
brew install lua@5.3
#创建软链接
cd /usr/local/bin/
ln -s lua5.3 lua

这个时候在控制台已经是可以使用,但是在sublime中使用cmd+b调试lua,会提示[errno 2] no such file or directory: ‘lua’,查看path路径,发现并没有/usr/local/bin目录,这时候需要通过包管理工具搜索并安装fix mac path插件。

配置快捷键打开终端

安装terminal插件,快捷键cmd+shift+t默认打开的是系统自带终端如果需要打开iterm,在 /users/用户名/library/application support/sublime text 3/packages/terminal目录找到terminal.sublime-settings,在terminal后面填入iterm2-v3.sh(“terminal”: “iterm2-v3.sh”)。