Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zz -> develop #3

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./custom.el
custom.el
Empty file removed custom.el
Empty file.
4 changes: 3 additions & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This function should only modify configuration layer settings."

;; List of configuration layers to load.
dotspacemacs-configuration-layers
'(
'(yaml
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press `SPC f e R' (Vim style) or
Expand All @@ -59,10 +59,12 @@ This function should only modify configuration layer settings."
treemacs
ii-elpa
ii-go
ii-mate
ii-org
ii-org-capture
ii-sql
ii-tools
ii-yaml
)

;; List of additional packages that will be installed without being
Expand Down
3 changes: 3 additions & 0 deletions layers/ii-go/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [[#description][Description]]
- [[#features][Features]]
- [[#install][Install]]
- [[#delve][Delve]]

* Description
This layer extends the spacemacs go layer with additional configuration for use in literate programming.
Expand All @@ -30,3 +31,5 @@ add =ii-go= to the existing =dotspacemacs-configuration-layers= list in this
file.

This layer assumes you have go installed. If not, you can install it following the guide [[https://golang.org/doc/install?download=go1.14.2.linux-amd64.tar.gz][on golang.org]]
** Delve
https://github.com/go-delve/delve/tree/master/Documentation/installation
2 changes: 2 additions & 0 deletions layers/ii-go/layers.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
;;;;

(configuration-layer/declare-layer 'go)
(configuration-layer/declare-layer 'lsp)
(configuration-layer/declare-layer 'dap)

;;; layers.el ends here
86 changes: 33 additions & 53 deletions layers/ii-go/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,53 @@
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: <zz@zz2>
;; URL: https://github.com/syl20bnr/spacemacs
;; Author: Zach Mandeville <zz@ii.coop>
;; URL: https://github.com/humacs/.spacemacs.d
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

;;; Commentary:

;; See the Spacemacs documentation and FAQs for instructions on how to implement
;; a new layer:
;;
;; SPC h SPC layers RET
;;
;;
;; Briefly, each package to be installed or configured by this layer should be
;; added to `ii-go-packages'. Then, for each package PACKAGE:
;;
;; - If PACKAGE is not referenced by any other Spacemacs layer, define a
;; function `ii-go/init-PACKAGE' to load and initialize the package.

;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so
;; define the functions `ii-go/pre-init-PACKAGE' and/or
;; `ii-go/post-init-PACKAGE' to customize the package as it is loaded.

;;; Code:

(defconst ii-go-packages
'(lsp-ui
'(;; lsp-ui ; part of lsp layer
;; go-dlv ; didn't quite fit the bill
(ob-go :location (recipe
:fetcher github
:repo "pope/ob-go")))
"The list of Lisp packages required by the ii-go layer.

Each entry is either:

1. A symbol, which is interpreted as a package to be installed, or

2. A list of the form (PACKAGE KEYS...), where PACKAGE is the
name of the package to be installed or loaded, and KEYS are
any number of keyword-value-pairs.

The following keys are accepted:

- :excluded (t or nil): Prevent the package from being loaded
if value is non-nil

- :location: Specify a custom installation location.
The following values are legal:

- The symbol `elpa' (default) means PACKAGE will be
installed using the Emacs package manager.

- The symbol `local' directs Spacemacs to load the file at
`./local/PACKAGE/PACKAGE.el'

- A list beginning with the symbol `recipe' is a melpa
recipe. See: https://github.com/milkypostman/melpa#recipe-format")
"ob-go AND debugging via lsp+dap+dlv")
(defun ii-go/init-ob-go ()
(use-package ob-go
;; TODO check if gi/bin is in path
:config
(setenv "PATH" (concat user-home-directory "go/bin:" (getenv "PATH")))
(setq exec-path (append exec-path (list (concat user-home-directory "go/bin")))
))
;; (defun ii-go/init-lsp-go ()
;; (use-package ob-go
;; :config
;; (setq
;; )
;; ;; :config
;; ;; (setenv "PATH" (concat user-home-directory "go/bin:" (getenv "PATH")))
;; )
)

(defun ii-go/post-init-lsp-ui ()
(setq go-backend #'lsp))



;;; packages.el ends here
(defun ii-go/post-init-dap-go ()
(dap-go-setup)
)
(defun ii-go/post-init-lsp-layer ()
(message "ii-go lsp-layer settings")
(setq-default
;; we install to ~/go/bin
lsp-gopls-server-path "~/go/bin/gopls"
)
)

;; (defun ii-go/init-go-dlv ()
;; (use-package go-dlv
;; ;; NOTE: for kubemacs, dlv may be in /usr/local/bin
;; ;; :config
;; ;; (setenv "PATH" (concat user-home-directory "go/bin:" (getenv "PATH")))
;; ))
25 changes: 25 additions & 0 deletions layers/ii-mate/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#+TITLE: ii-mate layer
# Document tags are separated with "|" char
# The example below contains 2 tags: "layer" and "web service"
# Avaliable tags are listed in <spacemacs_root>/.ci/spacedoc-cfg.edn
# under ":spacetools.spacedoc.config/valid-tags" section.
#+TAGS: layer|web service

# The maximum height of the logo should be 200 pixels.
[[img/ii-mate.png]]

# TOC links should be GitHub style anchors.
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]

* Description
This layer adds support for literate pair programming when doing dev-ops work. It is centered around using tmate in org src blocks, so that you can easily document code and see it executed on its own screen.
** Features:
- run tmate src blocks that will auto-trigger a tmate session to share

* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =ii-mate= to the existing =dotspacemacs-configuration-layers= list in this
file.
3 changes: 3 additions & 0 deletions layers/ii-mate/layers.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; L A Y E R S

(configuration-layer/declare-layer 'org)
105 changes: 105 additions & 0 deletions layers/ii-mate/local/iterm/iterm.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
;;; iterm.el - Send text to a running iTerm instance

(require 'pcase)
(require 'thingatpt)

(defvar iterm-default-thing 'line
"The \"thing\" to send if no region is active.
Can be any symbol understood by `bounds-of-thing-at-point'.")

(defvar iterm-empty-line-regexp "^[[:space:]]*$"
"Regexp to match empty lines, which will not be sent to iTerm.
Set to nil to disable removing empty lines.")

(defun iterm-escape-string (str)
(let* ((str (replace-regexp-in-string "\\\\" "\\\\" str nil t))
(str (replace-regexp-in-string "\"" "\\\"" str nil t))
(str (replace-regexp-in-string "'" "\\'" str nil t)))
str))

(defun iterm-last-char-p (str char)
(let ((length (length str)))
(and (> length 0)
(char-equal (elt str (- length 1)) char))))

(defun iterm-chop-newline (str)
(let ((length (length str)))
(if (iterm-last-char-p str ?\n)
(substring str 0 (- length 1))
str)))

(defun iterm-maybe-add-newline (str)
(if (iterm-last-char-p str ? )
(concat str "\n")
str))

(defun iterm-handle-newline (str)
(iterm-maybe-add-newline (iterm-chop-newline str)))

(defun iterm-maybe-remove-empty-lines (str)
(if iterm-empty-line-regexp
(let ((regexp iterm-empty-line-regexp)
(lines (split-string str "\n")))
(mapconcat #'identity
(delq nil (mapcar (lambda (line)
(unless (string-match-p regexp line)
line))
lines))
"\n"))
str))

(defun iterm-new-window-send-string (str)
"Send STR to a running iTerm instance."
(let* ((str (iterm-maybe-remove-empty-lines str))
(str (iterm-handle-newline str))
(str (iterm-escape-string str)))
(let ((cmd (concat "osascript "
"-e 'tell app \"iTerm\"' "
"-e 'tell current window' "
"-e 'create window with default profile' "
"-e $'tell current session to write text \"" str "\"' "
"-e 'end tell' "
"-e 'end tell' ")))
(shell-command cmd))))

(defun iterm-send-string (str)
"Send STR to a running iTerm instance."
(let* ((str (iterm-maybe-remove-empty-lines str))
(str (iterm-handle-newline str))
(str (iterm-escape-string str)))
(let ((cmd (concat "osascript "
"-e 'tell app \"iTerm\"' "
"-e 'tell current window' "
"-e 'tell current session' "
"-e $'write text \"" str "\"' "
"-e 'end tell' "
"-e 'end tell' "
"-e 'end tell' ")))
(shell-command cmd)
)))

(defun iterm-text-bounds ()
(pcase-let ((`(,beg . ,end) (if (use-region-p)
(cons (region-beginning) (region-end))
(bounds-of-thing-at-point
iterm-default-thing))))
(list beg end)))

(defun iterm-send-text (beg end)
"Send buffer text in region from BEG to END to iTerm.
If called interactively without an active region, send text near
point (determined by `iterm-default-thing') instead."
(interactive (iterm-text-bounds))
(let ((str (buffer-substring-no-properties beg end)))
(iterm-send-string str))
(forward-line 1))

(defun iterm-send-text-ruby (beg end)
"Send buffer text in region from BEG to END to iTerm.
If called interactively without an active region, send text near
point (determined by `iterm-default-thing') instead."
(interactive (iterm-text-bounds))
(let ((str (buffer-substring-no-properties beg end)))
(iterm-send-string (concat "begin\n" str "\nend")))
(forward-line 1))
(provide 'iterm)
Loading