#+PROPERTY: header-args :tangle "~/.emacs.d/config-programming.el" :comments both

* Pretty Symbols!
#+begin_src emacs-lisp
(global-prettify-symbols-mode t)
#+end_src
* irony
#+begin_src emacs-lisp
  (use-package irony
    :hook ((c++-mode . irony-mode)
           (c-mode . irony-mode)
           (objc-mode . irony-mode)))

  ;; (add-hook 'c++-mode-hook 'irony-mode)
  ;; (add-hook 'c-mode-hook 'irony-mode)
  ;; (add-hook 'objc-mode-hook 'irony-mode)

  ;; (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

  ;; (global-company-mode)
#+end_src

* Yasnippets
#+BEGIN_SRC emacs-lisp
  (use-package yasnippet)
  (use-package java-snippets)
  (define-key yas/keymap (kbd "<backtab>") 'yas-expand)
  (yas-global-mode 0)
#+END_SRC
* Projectile and dumb-jump
#+BEGIN_SRC emacs-lisp
  (use-package projectile
    :custom
    (projectile-enable-caching t))

  (use-package treemacs-projectile)
  (use-package helm-projectile)
  (use-package counsel-projectile)

  (defun projectile-stop-project-running ()
    (interactive)
    (if-let (buf (get-buffer "*compilation*"))
        (let ((kill-buffer-query-functions nil))
          (kill-buffer buf)
          (delete-window))
      (message "Project is not running")))

  (projectile-global-mode)
  ;; Deprecated?
  (counsel-projectile-mode)

  (ivy-set-occur 'counsel-projectile-switch-to-buffer 'ivy-switch-buffer-occur)

  (cons 'projectile-root-bottom-up
        (remove 'projectile-root-bottom-up
                projectile-project-root-files-functions))
  (setq projectile-indexing-method 'native)
  (setq projectile-completion-system 'ivy)
  (define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)
  (define-key projectile-command-map (kbd "C-a") 'projectile-add-known-project)
  (define-key projectile-command-map (kbd "C-r") 'projectile-remove-known-project)
  (define-key projectile-command-map (kbd "C-f") 'counsel-projectile-find-file)
  (define-key projectile-command-map (kbd "C-b") 'projectile-ibuffer)
  (define-key projectile-command-map (kbd "C-c") 'projectile-compile-project)
  (define-key projectile-command-map (kbd "C-d") 'projectile-stop-project-running)

  (defun this-is-a-project (dir)
    (interactive "f")
    (setq projectile-project-root dir)
    (set (make-local-variable 'dumb-jump-project) dir))

  (define-key projectile-command-map (kbd "C-t") 'this-is-a-project)
  (use-package dumb-jump)
  (dumb-jump-mode)
#+END_SRC
* hs-minor-mode
#+BEGIN_SRC emacs-lisp
  (defun set-hiding-indentation (column)
    (interactive "P")
    (set-selective-display
     (or column
         (unless selective-display
           (1+ (current-column))))))

  (defun set-hiding-indentation-to-point (column)
    (interactive "P")
    (if hs-minor-mode
        (if (condition-case nil
                (hs-toggle-hiding)
              (error t))
            (hs-show-all))
      (set-hiding-indentation column)))

  (global-set-key (kbd "C-=") 'hs-toggle-hiding)
  (global-set-key (kbd "C--") 'set-hiding-indentation-to-point)
  (add-hook 'c-mode-common-hook   'hs-minor-mode)
  (add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
  (add-hook 'java-mode-hook       'hs-minor-mode)
  (add-hook 'lisp-mode-hook       'hs-minor-mode)
  (add-hook 'perl-mode-hook       'hs-minor-mode)
  (add-hook 'sh-mode-hook         'hs-minor-mode)
#+END_SRC
* Ensime (scala)
#+BEGIN_SRC emacs-lisp
  (use-package ensime)
#+END_SRC
* SPACES
#+BEGIN_SRC emacs-lisp
  (setq TeX-auto-untabify 't)
  (setq indent-tabs-mode nil)
  (add-hook 'java-mode-hook
            (lambda () 
              (setq indent-tabs-mode nil)))
  (add-hook 'clojure-mode
             (lambda ()
              (setq indent-tabs-mode nil)))
#+END_SRC
* Geiser
#+BEGIN_SRC emacs-lisp
  (use-package geiser)
  (setq geiser-default-implementation 'chez)
#+END_SRC
* Cider
#+BEGIN_SRC emacs-lisp
  (use-package clj-refactor)
  (use-package cider)
  (use-package clojure-mode)
#+END_SRC
* YAML
#+BEGIN_SRC emacs-lisp
  (use-package yaml-mode)
#+END_SRC
* C#
#+BEGIN_SRC emacs-lisp
  (use-package csharp-mode)
  (use-package dotnet)
  (use-package omnisharp
    :bind (:map omnisharp-mode-map
            ([remap xref-find-definitions] . omnisharp-go-to-definition)
            ([remap xref-find-references] . omnisharp-find-usages)))
  (add-hook 'csharp-mode-hook 'omnisharp-mode)
  (add-hook 'csharp-mode-hook 'company-mode)
  (add-hook 'csharp-mode-hook 'flycheck-mode)
  (add-hook 'csharp-mode-hook 'auto-highlight-symbol-mode)
  (add-hook 'csharp-mode-hook 'dotnet-mode)
#+END_SRC
* React js
#+BEGIN_SRC emacs-lisp
  (use-package rjsx-mode)
#+END_SRC
* Processing
#+BEGIN_SRC emacs-lisp
  (use-package processing-mode)

  (setq processing-location "/usr/bin/processing-java")
#+END_SRC
* Treemacs
#+BEGIN_SRC emacs-lisp
  (use-package treemacs)
#+END_SRC
* Hy-mode
#+begin_src emacs-lisp
  (use-package hy-mode)
#+end_src
* glsl-mode
#+BEGIN_SRC emacs-lisp
  (autoload 'glsl-mode "glsl-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.glsl\\'" . glsl-mode))
  (add-to-list 'auto-mode-alist '("\\.vert\\'" . glsl-mode))
  (add-to-list 'auto-mode-alist '("\\.frag\\'" . glsl-mode))
  (add-to-list 'auto-mode-alist '("\\.geom\\'" . glsl-mode))
#+END_SRC
* indent-guide 
#+begin_src emacs-lisp
  (use-package indent-guide)
  ;(indent-guide-global-mode)
#+end_src
* maven support
#+begin_src emacs-lisp
  (use-package mvn)
#+end_src
* Setup-dev-environment
#+begin_src emacs-lisp
  (defun setup-devenv ()
    (interactive)
    (flycheck-list-errors)
    (treemacs)
    (dap-ui-locals)
    (when (y-or-n-p "Enter lsp? ")
      (lsp)))
#+end_src
* skeletor project templates
#+begin_src emacs-lisp
  (use-package skeletor)

  (skeletor-define-template "java-maven"
    :title "Java with Maven")
#+end_src
* Erlang
#+begin_src emacs-lisp
  (use-package erlang)

  (add-to-list 'load-path
               (ef "submodule/erlang_ls/"))

  (setq lsp-erlang-server-install-dir (ef "submodule/erlang_ls"))

  (defun my/erlang-keymap-hook ()
    (local-set-key (kbd "C-c C-c") 'erlang-compile))

  (add-hook 'erlang-mode-hook 'my/erlang-keymap-hook)
#+end_src
