在emacs中,只加载基础配置。项目配置用脚本加载。go语言使用go-langserver和lsp-mode,其他的yasnippet,补全,都是基础功能。
bash <(curl -L -s https://install.direct/go.sh)
;;<for line numbers>
;; if you clipboard don't use well, close numbers, then you can copy and paste
(global-linum-mode 1) ; always show line numbers
(setq linum-format "%4d| ")
(setq-default fill-column 80)
;;
;;<for find path backspace>
(global-set-key "\C-h" 'backward-delete-char-untabify)
(global-set-key "\d" 'delete-char)
;;
;; <for copy>
;; http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
;; I prefer using the "clipboard" selection (the one the
;; typically is used by c-c/c-v) before the primary selection
;; (that uses mouse-select/middle-button-click)
(setq x-select-enable-clipboard t)
;; If emacs is run in a terminal, the clipboard- functions have no
;; effect. Instead, we use of xsel, see
;; http://www.vergenet.net/~conrad/software/xsel/ -- "a command-line
;; program for getting and setting the contents of the X selection"
(unless window-system
(when (getenv "DISPLAY")
;; Callback for when user cuts
(defun xsel-cut-function (text &optional push)
;; Insert text to temp-buffer, and "send" content to xsel stdin
(with-temp-buffer
(insert text)
;; I prefer using the "clipboard" selection (the one the
;; typically is used by c-c/c-v) before the primary selection
;; (that uses mouse-select/middle-button-click)
(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))
;; Call back for when user pastes
(defun xsel-paste-function()
;; Find oout what is current selection by xsel. If it is different
;; from the top of the kill-ring (car kill-ring), then return
;; it. Else, nil is returned, so whatever is in the top of the
;; kill-ring will be used.
(let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
(unless (string= (car kill-ring) xsel-output)
xsel-output )))
;; Attach callbacks to hooks
(setq interprogram-cut-function 'xsel-cut-function)
(setq interprogram-paste-function 'xsel-paste-function)
;; Idea from
;; http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/
;; http://www.mail-archive.com/help-gnu-emacs@gnu.org/msg03577.html
))
;; </for copy>
;; <for ctags>
;; </for ctags>
所有emacs配置出现问题的原因都是对elisp了解少导致的,emacs的插件源有清华的也有emacs-china的,清华的地址:
(setq package-archives '(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
future:
(1)自动安装package,放到自定义目录
(2)项目中创建一个空的.projectile配置文件,当打开一个项目的文件夹后会自动打开响应的lsp后端,开启lsp-mode。
首先安装polipo,然后写配置文件:
#必填
socksParentProxy = "localhost:1080"
socksProxyType = socks5
安装lsp的go语言后端gopls,lsp-mode包括UI之类的提供一套共同的操作,配置不同的后端就可以做成和ide一样:
GO111MODULE=on https_proxy=127.0.0.1:8123 http_proxy=127.0.0.1:8123 go get -v golang.org/x/tools/gopls@latest
安装bingo后端。
go语言补全,跳转,需要的工具参考:
https://blog.yuantops.com/tech/emacs-config-go-dev-environ/
要么多试几次,将包下载下来,要么更改go.mod,增加replace配置,示例如下:
module tx
require github.com/sirupsen/logrus v1.2.0 // indirect
replace (
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac => github.com/golang/crypto v0.0.0-20180820150726-614d502a4dac
golang.org/x/net v0.0.0-20180821023952-922f4815f713 => github.com/golang/net v0.0.0-20180826012351-8a410e7b638d
golang.org/x/text v0.3.0 => github.com/golang/text v0.3.0
golang.org/x/sys v0.3.0=>github.com/golang/sys v0.3.0
)
如果过程中卡主了,可以使用nload,回车键切换查看ip流量是否正常。
有疑问加站长微信联系(非本文作者)