dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

README.org (4805B)


      1 [[https://github.com/emacs-csharp/csharp-mode/actions][file:https://github.com/emacs-csharp/csharp-mode/workflows/Build%20&%20Test/badge.svg?branch=master]]
      2 [[https://melpa.org/#/csharp-mode][file:https://melpa.org/packages/csharp-mode-badge.svg]]
      3 [[https://stable.melpa.org/#/csharp-mode][file:https://stable.melpa.org/packages/csharp-mode-badge.svg]]
      4 [[https://elpa.gnu.org/packages/csharp-mode.html][file:https://elpa.gnu.org/packages/csharp-mode.svg]]
      5 * csharp-mode
      6 
      7 This is a mode for editing C# in emacs. It's using CC mode or [[https://github.com/ubolonton/emacs-tree-sitter][tree-sitter]] for
      8 highlighting and indentation.
      9 
     10 ** Main features
     11 
     12 - font-lock and indent of C# syntax including:
     13   - all c# keywords and major syntax
     14   - attributes that decorate methods, classes, fields, properties
     15   - enum types
     16   - #if/#endif #region/#endregion
     17   - instance initializers
     18   - anonymous functions and methods
     19   - verbatim literal strings (those that begin with @)
     20   - generics 
     21 - intelligent insertion of matched pairs of curly braces.
     22 - compilation-mode support for msbuild, devenv and xbuild.
     23 
     24 ** tree-sitter support
     25 You can enable experimental tree sitter support for indentation and highlighting using
     26 #+begin_src elisp
     27   (use-package tree-sitter :ensure t)
     28   (use-package tree-sitter-langs :ensure t)
     29 
     30   (use-package csharp-mode
     31     :ensure t
     32     :config
     33     (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-tree-sitter-mode)))
     34 #+end_src
     35 If you are using this, clearly state so if you find any issues.
     36 
     37 Note that we don't depend on tree-sitter yet, so you have to manually install
     38 the packages involved.  The simplest way is to use the provided snippet above.
     39 
     40 *** Using and evolving the tree-sitter functionality.
     41 =tree-sitter= introduces a minor mode called =tree-sitter-debug-mode= where you can
     42 look at the actual syntax tree it produces.  If and when you spot missing or
     43 wrong syntax highlighting, look at how the patterns are written in
     44 =csharp-tree-sitter-mode.el=, then submit a pr with a couple new ones added.  When
     45 testing and debugging this, it is actually as simple as =M-x eval-buffer= on
     46 =csharp-tree-sitter-mode.el=, then =M-x revert-buffer= in the file you are testing.
     47 It should update and show the correct syntax highlighting. 
     48 
     49 
     50 So the development cycle is:
     51 - Spot missing syntax highlighting
     52 - View AST with =tree-sitter-debug-mode=
     53 - Locate offending part
     54 - Add new pattern
     55 - =M-x eval-buffer= in =csharp-tree-sitter-mode.el=
     56 - =M-x revert-buffer= inside your =some-test-file.cs=
     57 
     58 
     59 ** Usage
     60 
     61 This package is currently available on both ELPA and MELPA. Install using ~M-x
     62 package-install<RET>csharp-mode~.
     63 
     64 Once installed the package should be automatically used for files with a '.cs'-extension.
     65 
     66 Note: This package is also available on [[http://stable.melpa.org/][MELPA-stable]] for those who don't want or need
     67 bleeding edge development-versions.
     68 
     69 For a better experience you may want to enable electric-pair-mode when editing C#-files.
     70 To do so, add the following to your .emacs-file:
     71 
     72 #+BEGIN_SRC emacs-lisp
     73   (defun my-csharp-mode-hook ()
     74     ;; enable the stuff you want for C# here
     75     (electric-pair-mode 1)       ;; Emacs 24
     76     (electric-pair-local-mode 1) ;; Emacs 25
     77     )
     78   (add-hook 'csharp-mode-hook 'my-csharp-mode-hook)
     79 #+END_SRC
     80 
     81 For further mode-specific customization, ~M-x customize-group RET csharp RET~ will show available settings with documentation.
     82 
     83 For more advanced and IDE-like functionality we recommend using csharp-mode together
     84 with [[https://github.com/emacs-lsp/lsp-mode][lsp-mode]] or [[https://github.com/joaotavora/eglot][eglot]]
     85 
     86 * Attribution
     87 
     88 This repo was a fork of the code originally developed by Dylan R. E. Moonfire and
     89 further maintained by Dino Chiesa as hosted on [[https://code.google.com/p/csharpmode/][Google code]].
     90 
     91 ** New focus
     92 
     93 The original csharp-mode repo contained lots of different code for lots of different purposes,
     94 some finished, some not, some experimental, some not. Basiaclly things like ASPX-mode, TFS-mode,
     95 code completion backends, etc.
     96 
     97 All this original code can still be found in the [[https://github.com/josteink/csharp-mode/tree/extras][extras-branch]], but we have decided to
     98 go for a more focused approach and to throw out all dead or unused code, code we wont
     99 be maintaining.
    100 
    101 The goal: That what we package in csharp-mode actually works and works well.
    102 
    103 * ELPA
    104 This package aims to stay as close to mainline emacs as it can.  As such,
    105 paperwork with the FSF is needed for contributions of significant size.
    106 
    107 
    108 * License
    109 
    110 The original project was licensed under [[https://www.gnu.org/licenses/gpl-2.0.html][GPL v2+]], but after a rewrite in September
    111 2020, it was relicensed to GPLv3+