当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 1 Fork 0

Gemo / emacs 配置文件
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
coding.org 7.02 KB
一键复制 编辑 原始数据 按行查看 历史
Gemo 提交于 2020-10-10 17:21 . divided done

Coding 代码相关

Coding 代码相关

Company mode

 (use-package company
   :homepage https://github.com/company-mode/company-mode
   :ensure t
   :custom
   (company-idle-delay 0)
   (company-minimum-prefix-length 3)
   (company-show-numbers t)
   :hook(after-init . global-company-mode)
   )

 (if (display-graphic-p)
     (use-package company-posframe
	:ensure t
	:diminish
	:hook (company-mode . company-posframe-mode))
   )

需要安装tabnine

M-x company-tabnine-install-binary
 (use-package company-tabnine
   :ensure t
   :config
   (progn
     (add-to-list 'company-backends #'company-tabnine)
     ;; workaround for company-transformers
     (setq company-tabnine--disable-next-transform nil)
     (defun my-company--transform-candidates (func &rest args)
	(if (not company-tabnine--disable-next-transform)
	    (apply func args)
	  (setq company-tabnine--disable-next-transform nil)
	  (car args)))

     (defun my-company-tabnine (func &rest args)
	(when (eq (car args) 'candidates)
	  (setq company-tabnine--disable-next-transform t))
	(apply func args))

     (advice-add #'company--transform-candidates :around #'my-company--transform-candidates)
     (advice-add #'company-tabnine :around #'my-company-tabnine)

     ;; ignore deep tabnine message
     ;; The free version of TabNine is good enough,
     ;; and below code is recommended that TabNine not always
     ;; prompt me to purchase a paid version in a large project.
     (defadvice company-echo-show (around disable-tabnine-upgrade-message activate)
	(let ((company-message-func (ad-get-arg 0)))
	  (when (and company-message-func
		     (stringp (funcall company-message-func)))
	    (unless (string-match "The free version of TabNine only indexes up to" (funcall company-message-func))
	      ad-do-it))))
     ))

Yasnippet

(use-package yasnippet
  :ensure t
  :init (yas-global-mode 1)
  :hook ((term-mode-hook) . (lambda () (yas-minor-mode -1)))
  :config
  (setq yas/root-directory '(
			       (concat custom/emacs-d-root "snippets")
			       )
	  )
  )

Lsp mode

;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")

(use-package lsp-mode
  :ensure t
  :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
	   ;; if you want which-key integration
	   (lsp-mode . lsp-enable-which-key-integration))
  :commands lsp)

;; optionally
(use-package lsp-ui
  :ensure t
  :commands lsp-ui-mode)
;; if you are ivy user
(use-package lsp-ivy
  :ensure t
  :commands lsp-ivy-workspace-symbol)
(use-package lsp-treemacs
  :ensure t
  :commands lsp-treemacs-errors-list)

;; optionally if you want to use debugger
(use-package dap-mode
  :ensure t)
;; (use-package dap-LANGUAGE) to load the dap adapter for your language

ivy-xref

(use-package ivy-xref
  :ensure t
  :init
  ;; xref initialization is different in Emacs 27 - there are two different
  ;; variables which can be set rather than just one
  (when (>= emacs-major-version 27)
    (setq xref-show-definitions-function #'ivy-xref-show-defs))
  ;; Necessary in Emacs <27. In Emacs 27 it will affect all xref-based
  ;; commands other than xref-find-definitions (e.g. project-find-regexp)
  ;; as well
  (setq xref-show-xrefs-function #'ivy-xref-show-xrefs))

C/C++

(use-package ccls
  :ensure t
  :hook ((c-mode c++-mode objc-mode cuda-mode) .
	   (lambda () (require 'ccls) (lsp)))
  :config
  (setq ccls-executable "/usr/bin/ccls"))
# 如果没有安装pypi
# > Archlinux
yay -S python-pip
emacs ~/.config/pip/pip.conf

# > 添加内容 更换国内源
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

# > 或
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted mirrors.aliyun.com
# > 安装lsp
pip install cmake-language-server

## 为了方便更新,此处可以直接使用AUR来安装
yay -S cmake-language-server

Web

添加rome作为lsp

Perl

# perl language server
# > 先换源
#1. 终端执行 cpan 命令
$ cpan
#2. 增加源:
cpan[1]> o conf urllist push https://mirrors.aliyun.com/CPAN/
cpan[2]> o conf commit

# 还需要手动编辑 ~/.cpan/CPAN/MyConfig.pm 更换源的顺序

# 第一次进入 cpan 选择 sudo,否则无法正常安装
# 仅测试状况,需要重置cpan,直接删除~/.cpan

# 选用
cpan Term::Readline::Perl
cpan Log::Log4perl

# > 后安装lsp
cpan Perl::LanguageServer

## archlinux 可以直接安装 [现在不推荐,会携带许多不必要的包,部分依赖已经过期]
yay -S aur/perl-perl-languageserver-git

Lua

Archlinux 可以直接使用 AUR 安装,其他系统参考以下网址:

# Archlinux
yay -S aur/lua-language-server-git
(use-package lua-mode
  :ensure t
  )

Bash

# for bash
npm i -g bash-language-server
Emacs Lisp
1
https://gitee.com/gemone/emacs.d.git
git@gitee.com:gemone/emacs.d.git
gemone
emacs.d
emacs 配置文件
master

搜索帮助