...
 
Commits (3)
......@@ -108,3 +108,6 @@ alias gitdel='GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa.github-delbonis" git'
if [ -f $HOME/'.bashrc.local' ]; then
source $HOME/'.bashrc.local'
fi
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
......@@ -17,20 +17,37 @@
(package-initialize)
; macOS is dumb with how it handles sessions so we have to manually do this :(
;; macOS is dumb with how it handles sessions so we have to manually do this :(
(when (string-equal system-type "darwin")
;; This one just forces us to do use modules for things since not using them
;; is a *really really shitty thing to do*.
(setenv "GO111MODULE" "on")
;; We don't normally write darwin-specific things, like, ever, so it's safe
;; to assume Linux when running things from within Emacs.
(setenv "GOOS" "linux")
;; This copies some other envvars from the shell on startup.
(use-package exec-path-from-shell
:ensure t
:config
(exec-path-from-shell-copy-env "GOPATH") ; y u do dis 2 me?
(setq exec-path-from-shell-check-startup-files nil)) ; I know what I'm doing.
;(if (null (string-match-p "go/bin" (getenv "PATH")))
; (setenv "PATH" (concat (substitute-in-file-name "$HOME/.go/bin") ":" (getenv "PATH"))))
;(if (null (getenv "GOPATH"))
; (setenv "GOPATH" (substitute-in-file-name "$HOME/.go")))
(setenv "GO111MODULE" "off")
(exec-path-from-shell-initialize))
;; If the dir we're actually running from is ".dotfiles", like I always do, then
;; set this to be the full path.
;; This is to help out with the gopls wrapper later on down the road.
(defvar dotdotfiles-path
(let ((dotemacs-parent (file-name-directory
(expand-file-name
(file-truename load-file-name)))))
(message ".emacs real parent is %s" dotemacs-parent)
(if (string-equal (file-name-nondirectory (directory-file-name dotemacs-parent))
".dotfiles")
dotemacs-parent
nil)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Core stuff
......@@ -51,22 +68,64 @@
(setq neo-theme 'nerd))
(neotree-show)
;; Custom implementation of a lsp-mode function to let us use our own language
;; servers by absolute path, if we have to.
(defun dotemacs-custom-lsp-server-present? (final-command)
"Check whether FINAL-COMMAND is present."
;; executable-find only gained support for remote checks after 27 release
(or (and (cond
((not (file-remote-p default-directory))
(executable-find (cl-first final-command)))
((version<= "27.0" emacs-version)
(with-no-warnings (executable-find (cl-first final-command) (file-remote-p default-directory))))
(t))
(prog1 t
(lsp-log "Command \"%s\" is present on the path." (s-join " " final-command))))
;; This is the fun bit here.
(and (file-name-absolute-p (cl-first final-command))
(file-exists-p (cl-first final-command))
(prog1 t
(lsp-log "Command \"%s\" is present at an absolute path." (s-join " " final-command))))
(ignore (lsp-log "Command \"%s\" is not present on the path." (s-join " " final-command)))))
(use-package lsp-mode
:ensure t
:hook (prog-mode . lsp)
:commands (lsp lsp-deferred)
:config
(setq lsp-enable-snippet nil))
; TODO Make this look nicer.
;(use-package lsp-ui
; :ensure t
; :commands lsp-ui)
;; blah
(setq lsp-enable-snippet nil)
;; Things interact poorly with this, at least on macOS. Maybe ok on Linux.
(setq lsp-prefer-flymake :none)
;; Rewrite the function to check if a server is present since we use absolute paths now.
(defun lsp-server-present? (final-command)
(dotemacs-custom-lsp-server-present? final-command))
;; Hook in our gopls wrapper in case we need it.
(when dotdotfiles-path
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(lambda ()
(cons (concat dotdotfiles-path "gopls-cd-wrapper.sh")
lsp-gopls-server-args)))
:major-modes '(go-mode)
:priority 5
:server-id 'goplsw
:library-folders-fn (lambda (_workspace)
lsp-clients-go-library-directories)))))
;; TODO Make this look nicer.
;;(use-package lsp-ui
;; :ensure t
;; :commands lsp-ui)
(use-package company-lsp
:ensure t
:commands company-lsp)
;; TODO Actually set this up.
(use-package tramp
:ensure t)
......@@ -108,17 +167,17 @@
:after rust-mode
:hook (rust-mode . cargo-minor-mode))
; BROKEN
;(use-package flycheck-rust
; :hook ((flycheck-mode . flycheck-rust-setup)))
;; BROKEN
;;(use-package flycheck-rust
;; :hook ((flycheck-mode . flycheck-rust-setup)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Go Stuff
; What GOPATH was on startup.
;; What GOPATH was on startup.
(defvar dotemacs-original-gopath (getenv "GOPATH"))
; Reads the ".gopath" dir in the current dir and finds the absolute path.
;; Reads the ".gopath" dir in the current dir and finds the absolute path.
(defun dotemacs-dotgopath-resolve (projdir)
(let ((dgp-path (expand-file-name ".gopath" projdir)))
(if (file-exists-p dgp-path)
......@@ -131,6 +190,7 @@
(use-package go-mode
:ensure t
:after lsp-mode
:hook ((before-save . gofmt-before-save)
(go-mode . company-lsp)
(lsp-before-initialize
......@@ -163,6 +223,7 @@
(add-hook 'c-mode-common-hook 'hs-minor-mode)
(setq c-default-style "linux")
(setq c-basic-offset t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Other formats
......@@ -187,23 +248,26 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Other stuff
; which key just runs everywhere
;; Make indents prettier
(setq tab-width 4)
;; which key just runs everywhere
(use-package which-key
:ensure t)
(which-key-mode)
; Column numbers!
;; Column numbers!
(setq column-number-mode t)
; Nicer navigation.
;; Nicer navigation.
(global-set-key (kbd "C-<PageUp>") 'windmove-left)
(global-set-key (kbd "C-<PageDown>") 'windmove-right)
; Smoother scrolling
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
;; Smoother scrolling
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; one line at a time
(setq mouse-wheel-progressive-speed nil) ; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ; scroll window under mouse
(setq scroll-step 1) ; keyboard scroll one line at a time
(setq calendar-latitude 42)
(setq calendar-longitude -71)
......
......@@ -49,3 +49,8 @@ if [ -d ~/bin ]; then
fi
fi
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#!/bin/bash
# Filename of the flag to say "hey cd to somewhere that's not here".
GMP_FILENAME='.gomodpath'
# Give a warning to people:
# "when will you learn?
# when will you learn?
# that your actions have consequences!"
echo -e "I would like to take this opportunity to remind you that Go sucks, and you shouldn't use it.\n" 1>&2
# Here we check if there's a file called ".gomodpath", and if there is then we
# read it and cd to that directory.
if [ -f $GMP_FILENAME ]; then
gmp=$(cat $GMP_FILENAME)
echo 'switching directory to' $gmp 1>&2
export GO111MODULE=on
cd $gmp
fi
# Let's dump the go env here, just to figure out what we're really looking at.
go env 1>&2
# And now just exec gopls, our work here (if we did any) is done and we don't
# need to exist anymore.
exec gopls [email protected]