Fork me on GitHub
#spacemacs
<
2017-11-22
>
arijun07:11:54

I made a new file that ended with .cljs, but when I opened the file I was in fundamental mode not clojurescript mode, so I don't get any coloring, bracket matching, etc. How do I change the mode? Why didn't it automatically go into the appropriate mode in the first place?

sam1608:11:03

Hello developers, i have now been using spacemacs for my clojure development since last 4 months but there is one feature which i am still not able to configure. That is auto-complete for inbuilt library functions, eg. when i type fil then it should already suggest me filter or any other functions available for it Currently i have installed auto-completion layer in my spacemacs and set (global-company-mode t) which enables dumb auto-complete everywhere that is now when i type anything if that function or variable name is used previously only then it will suggest me, its not smart. I have did alot of research and read ac-cider gives it but it shows now its depricated and i am not able to configure it in my spacemacs. I have been stuggling for this since long now and i am pretty sure someone might have configured this in there setup can anyone help me out.??

jumar10:11:29

@sam16 it seems to work for me properly:

jumar10:11:31

I don't have anything special here - just auto-completion layer

jumar10:11:03

nothing else (searching for "complet")

sam1610:11:56

which hooks have you added to clojure mode?

jumar10:11:33

(spacemacs/add-flycheck-hook 'clojure-mode)
  (eval-after-load 'clojure-mode '(sayid-setup-package))

sam1610:11:33

have you connected to a cider repl?

sam1610:11:51

i think that might be the issue i am not connected to any repl currently as doing an cljs project

andre.stylianos11:11:53

just to mention but cljs also provides a repl

jumar10:11:02

it doesn't work without repl

jumar10:11:08

only basic emacs auto complete

sam1610:11:22

ohh, thank you. i didnt knew that.

sam1610:11:31

Thanx for the info

jumar10:11:37

no problem 🙂

jumar11:11:24

btw. I can get the auto-completion even with cljs buffer

sam1611:11:48

cider connected?

jumar11:11:58

yes, I got the auto complete even with basic clojure repl (although I can't eval buffer without proper cljs repl)

sam1611:11:38

my current status

jumar11:11:04

I don't do much cljs work, but I usually use figwheel and when I run

(use 'figwheel-sidecar.repl-api)

(start-figwheel!)

(cljs-repl)

It works completely

Sam H11:11:08

might need to eval the buffer?

sam1611:11:13

opened a cljs file but no repl connected

sam1611:11:58

i usually do an lein figwheel where i get a cljs repl but i dont connect it in my spacemacs.

jumar11:11:30

so you should give it a try. Or at least I prefer that style 🙂

sam1611:11:45

you mean connect my cljs repl here?

jumar11:11:23

yes, connect it with your editor

jumar11:11:04

I also tried to run lein figwheel externally and then connect to the figwheel repl server via cider-connect but in that case auto-complete doesn't work (I guess it doesn't work in figwheel repl either)

sam1611:11:29

didnt work with me too 😞

sam1611:11:37

wait i will run a clojrue repl

sam1611:11:40

in any other project

sam1611:11:47

and then open this cljs file

sam1611:11:01

it should work right as it only needs a repl connected to cider. right??

jumar11:11:12

yes, it should - I associated the buffer with completely unrelated clojure project repl and basic clojure autocomplete works

sam1611:11:40

i have a working clojure project

sam1611:11:45

trying to connect it now

sam1611:11:50

connected repl

sam1611:11:56

didnt work

sam1611:11:10

doesnt even work in clojure project clj file too

sam1611:11:45

do i need to add flycheck for it?

sam1611:11:51

added your flycheck line to my .spacemacs restarted spacemacs

sam1611:11:00

restarted repl in terminal

sam1611:11:16

again connected to spacemacs

sam1611:11:39

and even now in my clj file also not showing complete

jumar11:11:24

fllycheck has nothing to do with that - it's basically a linter for clojure code

sam1611:11:00

do you mind sharing your .spacemacs? i will move my .spacemacs to backup and maybe try urs

sam1611:11:11

i will share my config wait

jumar11:11:06

you obviously have problem with the basic auto complete. I'd suggest to experiment on a very basic clojure project. How do you run the repl? Did you run it through cider-jack-in?

sam1611:11:21

no buddy i make a repl in terminal and connect using cider-connect (Ctrl c + Meta c)

sam1611:11:31

my current config for clojure mode

sam1611:11:06

(global-company-mode t) (add-hook 'clojure-mode-hook 'linum-mode) (add-hook 'clojure-mode-hook 'paredit-mode) (spacemacs/add-flycheck-hook 'clojure-mode) (add-hook 'clojure-mode-hook 'show-paren-mode) (global-visual-line-mode t)

jumar11:11:08

when I run it in terminal it doesn't work for me either. Why don't run it with cider itself?

jumar11:11:39

(I guess, there are some crucial config/dependencies missing that cider will inject automatically)

sam1611:11:22

in your dependencies do you have cider somewhere?

jumar11:11:31

I don't think so

sam1611:11:15

created a new project called try-ac

jumar11:11:37

it used to be the case that you had to add cider-nrepl & company to your profiles.clj but everything is injected automatically by cider now

sam1611:11:42

and just opened it now creating a local repl and will try to connect it in spacemacs and then tell you in a min

sam1611:11:53

no fruits

jumar11:11:53

do you have auto-completion in dotspacemacs-configuration-layers

sam1612:11:06

yes i do have wait i will share my config-layers too

jumar12:11:08

otherwise I ran out of ideas

sam1612:11:29

ivy auto-completion better-defaults emacs-lisp git markdown (org :variables org-enable-github-support t) sql nginx javascript yaml html csv clojure (shell :variables shell-default-height 30 shell-default-position 'bottom) spell-checking syntax-checking

sam1612:11:34

my layers

sam1612:11:11

have you added this line (global-company-mode t)?

sam1612:11:50

in user-config

sam1612:11:00

wait i will disable it and restart emacs

sam1612:11:05

spacemacs*

jumar12:11:25

if that's of any use for you, then here's my (almost complete) user-config

;; of Emacs functions like `get-buffer-window`
  (setq source-directory "/Users/jumar/workspace/emacs/emacs-sources/emacs-25.2")
  ;; for some reason setting source-directory didn't help Spacemacs to find proper sources
  ;; although it should: 
  (setq find-function-C-source-directory "/Users/jumar/workspace/emacs/emacs-sources/emacs-25.2/src")

  ;; set indent level to 2 for pascal (default is 3) since this is the standard indentation
  ;; suggested by coding style 
  (setq pascal-indent-level 2)

  ;; web mode indentation is 2 spaces - HTML, CSS, JavaScript
  (setq js2-basic-offset 2)
  (setq js-indent-level 2)
  (setq css-indent-offset 2)
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2)
  (setq web-mode-attr-indent-offset 2)

  ;; skewer for live editing HTML, CSS, JavaScript
  ;;  ?
  ;; (skewer-setup)
  (add-hook 'js2-mode-hook 'skewer-mode)
  (add-hook 'css-mode-hook 'skewer-css-mode)
  ;; this is different from standard `html-mode-hook` used by `skewer-setup` by default
  (add-hook 'web-mode-hook 'skewer-html-mode)


  ;;; CIDER

  ;; cider pretty print to avoid large strings freeze the REPL
  ;; check  
  ;; you can also use M-x cider-repl-toggle-pretty-printing RET
  (setq  cider-repl-use-pretty-printing t)

  ;; save history to file: 
  (setq cider-repl-wrap-history t)
  (setq cider-repl-history-size 1000)
  (setq cider-repl-history-file "~/.cider-repl-history")

  ;; cider debugger - greater output length; default is 10
  (setq cider-debug-print-length 30)

  ;; eclim for java code completion: 

        eclim-executable "~/tools/java/eclipse/Eclipse.app/Contents/Eclipse/eclim"
        eclimd-executable "~/tools/java/eclipse/Eclipse.app/Contents/Eclipse/eclimd")

  ;; clojure syntax checking using flycheck-joker: 
  (require 'flycheck-joker)
  (spacemacs/add-flycheck-hook 'clojure-mode)
  (spacemacs/add-flycheck-hook 'clojurescript-mode)

  ;; and 
  ;; (eval-after-load 'flycheck '(flycheck-clojure-setup))
  ;; (add-hook 'after-init-hook #'global-flycheck-mode)

  ;; sayid tracing support: 
  (eval-after-load 'clojure-mode '(sayid-setup-package))

  ;; java class files diassembler
  ;; without this, automatic disassembling doesn't work
  (require 'autodisass-java-bytecode)

  ;;; projectile

  ;; automatically create test file if it's missing
  (setq projectile-create-missing-test-files t)

sam1612:11:02

tysm i will check

jumar12:11:08

and here are my layers

(
     graphviz
     nginx
     haskell
     csv
     asciidoc
     yaml
     python
     javascript
     php
     sql
     html
     markdown
     clojure
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
     ;; <M-m f e R> (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     helm
     auto-completion
     better-defaults
     emacs-lisp
     git
     github
     ;; org
     shell
     ;; (shell :variables
     ;;        shell-default-height 30
     ;;        shell-default-position 'bottom)
     ;; spell-checking
     ;; version-control

     ;; my custom layers
     syntax-checking
     java
     ;; django-web-mode for Selmer templates: 
     django
     ;; for integration with Dash documentation tool: 
     dash
     ;; nice REST client - see 
     restclient
     ;; ranger layer - alternative to dired mode
     ranger
     )

sam1612:11:10

removed that line

sam1612:11:23

even my dumb auto-complete aint working nw

sam1612:11:48

thanx for your time i will comback if solved the issue

jumar12:11:21

omg. sorry, than the last tip I can give you is to try fresh spacemacs installation and add only the auto-completion layer and see how this works.

sam1612:11:44

ya that will be the last resort only

sam1612:11:58

thank you for your time i will keep looking for the solution

sam1612:11:03

to add clojure mode you jsut add it to your layers right and restart right?

sam1612:11:28

just last thing can you share a screenshot of you minor modes when you are in clojure file

sam1612:11:34

like i have shared

sam1612:11:42

this is what i have

sam1612:11:52

plz check the group cant attach in thread

jumar12:11:14

can't see much there. btw. I'm not even sure if auto-completion is required for the thing you want. I remember I had to install it to get proper expansion on TAB

sam1612:11:15

i have read that its necesary to have auto-complete for completion in clojure

vuuvi15:11:07

@eggsyntax and @chris here’s a nice gist with a bunch of keybindings: https://gist.github.com/robphoenix/9e4db767ab5c912fb558

practicalli-johnny15:11:58

@sam16 you can start a clojure repl from within Spacemacs using clojure-jack-in or clojurescript repl using clojurescript-jack-in (this starts both a clojure & clojurescript repl). You should only need the clojure layer for this to work, no hooks required. Adding the autocomplete layer will automatically give you autocomplete (usually need to restart emacs after adding this layer) My .spacemacs configuration is at: https://gist.github.com/jr0cket/53cb480eba71fa9867adeb8db712393c Also, create a simple project to test your Spacemacs setup, eg. lein new figwheel hello-world.

vuuvi19:11:41

anyone know how I can redefine the home and end keys?

vuuvi19:11:01

I keep accidently hitting them and having them take me to the end of a file. It’s very frustrating

chris19:11:18

(unbind-key (kbd "<home>"))

chris19:11:00

(unbind-key (kbd "<end>"))