├── .github
├── FUNDING.yml
├── dependabot.yml
├── pull_request_template.md
└── workflows
│ ├── markdownlint.yml
│ ├── nvim-type-check.yml
│ ├── panvimdoc.yml
│ ├── pr-title.yml
│ ├── stale-bot.yml
│ └── stylua.yml
├── .gitignore
├── .luarc.json
├── .markdownlint.yaml
├── .stylua.toml
├── CITATION.cff
├── Justfile
├── LICENSE
├── README.md
├── doc
└── nvim-kickstart-python.txt
├── kickstart-python.lua
├── treesitter-or-semshi.md
└── treesitter-vs-semshi
├── both.png
├── neither.png
├── semshi.png
└── treesitter.png
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/displaying-a-sponsor-button-in-your-repository
2 |
3 | custom: https://www.paypal.me/ChrisGrieser
4 | ko_fi: pseudometa
5 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | commit-message:
8 | prefix: "chore(dependabot): "
9 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## What problem does this PR solve?
2 |
3 | ## How does the PR solve it?
4 |
5 | ## Checklist
6 | - [ ] Used only `camelCase` variable names.
7 | - [ ] If functionality is added or modified, also made respective changes to the
8 | `README.md` (the `.txt` file is auto-generated and does not need to be
9 | modified).
10 |
--------------------------------------------------------------------------------
/.github/workflows/markdownlint.yml:
--------------------------------------------------------------------------------
1 | name: Markdownlint check
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | paths:
7 | - "**.md"
8 | - ".github/workflows/markdownlint.yml"
9 | - ".markdownlint.*" # markdownlint config files
10 | pull_request:
11 | paths:
12 | - "**.md"
13 |
14 | jobs:
15 | markdownlint:
16 | name: Markdownlint
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v4
20 | - uses: DavidAnson/markdownlint-cli2-action@v20
21 | with:
22 | globs: "**/*.md"
23 |
--------------------------------------------------------------------------------
/.github/workflows/nvim-type-check.yml:
--------------------------------------------------------------------------------
1 | name: nvim type check
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | paths: ["**.lua"]
7 | pull_request:
8 | paths: ["**.lua"]
9 |
10 | jobs:
11 | build:
12 | name: nvim type check
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: stevearc/nvim-typecheck-action@v2
17 |
--------------------------------------------------------------------------------
/.github/workflows/panvimdoc.yml:
--------------------------------------------------------------------------------
1 | name: panvimdoc
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | paths:
7 | - README.md
8 | - .github/workflows/panvimdoc.yml
9 | workflow_dispatch: {} # allows manual execution
10 |
11 | permissions:
12 | contents: write
13 |
14 | #───────────────────────────────────────────────────────────────────────────────
15 |
16 | jobs:
17 | docs:
18 | runs-on: ubuntu-latest
19 | name: README.md to vimdoc
20 | steps:
21 | - uses: actions/checkout@v4
22 | - run: git pull # fix failure when multiple commits are pushed in succession
23 | - run: mkdir -p doc
24 |
25 | - name: panvimdoc
26 | uses: kdheepak/panvimdoc@main
27 | with:
28 | vimdoc: ${{ github.event.repository.name }}
29 | version: "Neovim"
30 | demojify: true
31 | treesitter: true
32 |
33 | - run: git pull
34 | - name: push changes
35 | uses: stefanzweifel/git-auto-commit-action@v5
36 | with:
37 | commit_message: "chore: auto-generate vimdocs"
38 | branch: ${{ github.head_ref }}
39 |
--------------------------------------------------------------------------------
/.github/workflows/pr-title.yml:
--------------------------------------------------------------------------------
1 | name: PR title
2 |
3 | on:
4 | pull_request_target:
5 | types:
6 | - opened
7 | - edited
8 | - synchronize
9 | - reopened
10 | - ready_for_review
11 |
12 | permissions:
13 | pull-requests: read
14 |
15 | jobs:
16 | semantic-pull-request:
17 | name: Check PR title
18 | runs-on: ubuntu-latest
19 | steps:
20 | - uses: amannn/action-semantic-pull-request@v5
21 | env:
22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 | with:
24 | requireScope: false
25 | subjectPattern: ^(?![A-Z]).+$ # disallow title starting with capital
26 | types: | # add `improv` to the list of allowed types
27 | improv
28 | fix
29 | feat
30 | refactor
31 | build
32 | ci
33 | style
34 | test
35 | chore
36 | perf
37 | docs
38 | break
39 | revert
40 |
--------------------------------------------------------------------------------
/.github/workflows/stale-bot.yml:
--------------------------------------------------------------------------------
1 | name: Stale bot
2 | on:
3 | schedule:
4 | - cron: "18 04 * * 3"
5 |
6 | permissions:
7 | issues: write
8 | pull-requests: write
9 |
10 | jobs:
11 | stale:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Close stale issues
15 | uses: actions/stale@v9
16 | with:
17 | repo-token: ${{ secrets.GITHUB_TOKEN }}
18 |
19 | # DOCS https://github.com/actions/stale#all-options
20 | days-before-stale: 180
21 | days-before-close: 7
22 | stale-issue-label: "Stale"
23 | stale-issue-message: |
24 | This issue has been automatically marked as stale.
25 | **If this issue is still affecting you, please leave any comment**, for example "bump", and it will be kept open.
26 | close-issue-message: |
27 | This issue has been closed due to inactivity, and will not be monitored.
28 |
--------------------------------------------------------------------------------
/.github/workflows/stylua.yml:
--------------------------------------------------------------------------------
1 | name: Stylua check
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | paths: ["**.lua"]
7 | pull_request:
8 | paths: ["**.lua"]
9 |
10 | jobs:
11 | stylua:
12 | name: Stylua
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: JohnnyMorganz/stylua-action@v4
17 | with:
18 | token: ${{ secrets.GITHUB_TOKEN }}
19 | version: latest
20 | args: --check .
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # help-tags auto-generated by lazy.nvim
2 | doc/tags
3 |
--------------------------------------------------------------------------------
/.luarc.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime.version": "LuaJIT",
3 | "diagnostics.globals": ["vim"]
4 | }
5 |
--------------------------------------------------------------------------------
/.markdownlint.yaml:
--------------------------------------------------------------------------------
1 | # Defaults https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
2 | # DOCS https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md
3 | #───────────────────────────────────────────────────────────────────────────────
4 |
5 | # MODIFIED SETTINGS
6 | blanks-around-headings:
7 | lines_below: 0 # space waster
8 | ul-style: { style: sublist }
9 |
10 | # not autofixable
11 | ol-prefix: { style: ordered }
12 | line-length:
13 | tables: false
14 | code_blocks: false
15 | no-inline-html:
16 | allowed_elements: [img, details, summary, kbd, a, br]
17 |
18 | #─────────────────────────────────────────────────────────────────────────────
19 | # DISABLED
20 | ul-indent: false # not compatible with using tabs
21 | no-hard-tabs: false # taken care of by editorconfig
22 | blanks-around-lists: false # space waster
23 | first-line-heading: false # e.g., ignore-comments
24 | no-emphasis-as-heading: false # sometimes useful
25 |
--------------------------------------------------------------------------------
/.stylua.toml:
--------------------------------------------------------------------------------
1 | collapse_simple_statement = "Always"
2 |
--------------------------------------------------------------------------------
/CITATION.cff:
--------------------------------------------------------------------------------
1 | # vim: filetype=yaml
2 | # yaml-language-server: $schema=https://raw.githubusercontent.com/citation-file-format/citation-file-format/main/schema.json
3 | # DOCS https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md
4 | #───────────────────────────────────────────────────────────────────────────────
5 |
6 | message: If you use this software, please cite it using these metadata.
7 | title: nvim-kickstart-python
8 | abstract: A launch point for your nvim configuration for Python.
9 | type: software
10 | authors:
11 | - family-names: Grieser
12 | given-names: Christopher
13 | orcid: "https://orcid.org/0000-0002-0767-9496"
14 | commit: "ecc7572"
15 | date-released: "2023-11-28"
16 | repository-code: "https://github.com/chrisgrieser/nvim-kickstart-python"
17 | keywords:
18 | - nvim
19 | - starter configuration
20 | - python
21 | cff-version: 1.2.0
22 | license: MIT
23 |
--------------------------------------------------------------------------------
/Justfile:
--------------------------------------------------------------------------------
1 | set quiet := true
2 |
3 | masonPath := "$HOME/.local/share/nvim/mason/bin/"
4 |
5 | #───────────────────────────────────────────────────────────────────────────────
6 |
7 | stylua:
8 | #!/usr/bin/env zsh
9 | {{ masonPath }}/stylua --check --output-format=summary . && return 0
10 | {{ masonPath }}/stylua .
11 | echo "\nFiles formatted."
12 |
13 | lua_ls_check:
14 | {{ masonPath }}/lua-language-server --check .
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 pseudometa
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # nvim-kickstart-python
3 |
4 |
5 | A launch point for your nvim config for python.
6 |
7 | Similar to [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim), but
8 | specifically for python.
9 |
10 |
11 |
12 | - [Motivation](#motivation)
13 | - [Philosophy & Features](#philosophy--features)
14 | - [Recommendation](#recommendation)
15 | - [Download](#download)
16 | - [Syntax Highlighting](#syntax-highlighting)
17 | - [Additional plugins of interest](#additional-plugins-of-interest)
18 | - [Recommended Citation](#recommended-citation)
19 | - [Credits](#credits)
20 |
21 |
22 |
23 | ## Motivation
24 | While there are quite a few great nvim distros and nvim starter configs out
25 | there, one thing I somewhat missed was a base config for specific languages. I
26 | recently started to learn python and was missing a minimal example what the
27 | state-of-the-art nvim setup specifically for python is.
28 |
29 | After figuring most of it out, I decided to publish this config for others to
30 | use. It is intended as a launch point for python devs switching to nvim, or as a
31 | reference for nvim users who want to start doing python development.
32 |
33 | ## Philosophy & Features
34 | - This is not a nvim distro, this is a *minimal* nvim config specifically for
35 | python. It's intended as a starting point for creating your own config.
36 | - Requirement: nvim 0.10.
37 | - ~15 plugins, ~350 lines, everything in one single file.
38 | - Includes detailed comments explaining what the config does.
39 | - The config can be fully bootstrapped: all plugins and tools are automatically
40 | installed on startup.
41 | - Uses the current state-of-the-art of the nvim plugin ecosystem.
42 | - Includes some common tooling for python development:
43 | + LSP (Completion, Typing): `pyright`
44 | + Linting (Diagnostics): `ruff`
45 | + Debugger: `debugpy`
46 | + Embedded REPL: `ipython` (if not installed, falls back to `python3`)
47 | - In addition, this config includes editing utilities specifically for python,
48 | like for example docstrings creation, selecting virtual environments, or
49 | auto-converting f-strings.
50 |
51 | ## Recommendation
52 | Go through the [kickstart-python.lua](./kickstart-python.lua), it is commented in
53 | detail.
54 |
55 | You can copypaste the config into you current `init.lua` to use it as a starting
56 | point for your regular config, or you can copypaste parts of it into your
57 | existing config.
58 |
59 | ## Download
60 | `kickstart-python` requires at least nvim 0.10.
61 |
62 | Download the [kickstart-python.lua](./kickstart-python.lua) file and run Neovim
63 | with it:
64 |
65 | ```bash
66 | # download the config
67 | curl --remote-name "https://raw.githubusercontent.com/chrisgrieser/nvim-kickstart-python/main/kickstart-python.lua"
68 |
69 | # start neovim with the config, opening a file `foobar.py`
70 | # (any existing config you are using remains untouched)
71 | nvim -u kickstart-python.lua foobar.py
72 | ```
73 |
74 | The config automatically installs all the plugins and tooling needed.
75 |
76 |
77 | ## Syntax Highlighting
78 | Is provided by the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
79 | plugin and/or the [semshi](https://github.com/numirias/semshi) plugin. The latter
80 | requires `pynvim` (`python3 -m pip install pynvim`) to be installed.
81 |
82 | Both provide better highlighting, Treesitter is considered the more "modern"
83 | approach. Treesitter covers some cases `semshi` does not and vice versa. Have a
84 | [look at the comparison](./treesitter-or-semshi.md) to decide for yourself which
85 | one to use. The config uses Treesitter as the more modern approach.
86 |
87 | ## Additional plugins of interest
88 | These plugins are not included in the config, but they are worth mentioning, as
89 | some people might be interested in them:
90 | - [nvim-various-textobjs](https://github.com/chrisgrieser/nvim-various-textobjs):
91 | various indentation-based text objects
92 | - [NotebookNavigator](https://github.com/GCBallesteros/NotebookNavigator.nvim):
93 | Jupyter Notebook emulation
94 | - [magma.nvim](https://github.com/dccsillag/magma-nvim): Jupyter Notebook integration
95 | - [ropify.nvim](https://github.com/niqodea/ropify): `ropify` integration
96 | - [nvim-conda](https://github.com/kmontocam/nvim-conda): `conda` environment selector
97 | - [nvim-lspimport](https://github.com/stevanmilic/nvim-lspimport): Automatically
98 | resolves imports for `pyright`.
99 | - [jupytext.nvim](https://github.com/GCBallesteros/jupytext.nvim): Convert
100 | Jupyter Notebooks to code and back.
101 | - [py-requirements.nvim](https://github.com/MeanderingProgrammer/py-requirements.nvim):
102 | Helps manage python requirements.
103 | - [venv-selector](https://github.com/linux-cultist/venv-selector.nvim): switch
104 | virtual environments
105 | - [python-import](https://github.com/kiyoon/python-import.nvim)
106 |
107 | ## Recommended Citation
108 | You can cite this software project as:
109 |
110 | ```txt
111 | Grieser, C. (2023). nvim-kickstart-python [Computer software].
112 | https://github.com/chrisgrieser/nvim-kickstart-python
113 | ```
114 |
115 | ## Credits
116 | [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) as an example how
117 | to do this.
118 |
119 | In my day job, I am a sociologist studying the social mechanisms underlying the
120 | digital economy. For my PhD project, I investigate the governance of the app
121 | economy and how software ecosystems manage the tension between innovation and
122 | compatibility. If you are interested in this subject, feel free to get in touch.
123 |
124 | - [Website](https://chris-grieser.de/)
125 | - [Mastodon](https://pkm.social/@pseudometa)
126 | - [ResearchGate](https://www.researchgate.net/profile/Christopher-Grieser)
127 | - [LinkedIn](https://www.linkedin.com/in/christopher-grieser-ba693b17a/)
128 |
129 |
132 |
--------------------------------------------------------------------------------
/doc/nvim-kickstart-python.txt:
--------------------------------------------------------------------------------
1 | *nvim-kickstart-python.txt* For Neovim Last change: 2025 May 03
2 |
3 | ==============================================================================
4 | Table of Contents *nvim-kickstart-python-table-of-contents*
5 |
6 | 1. nvim-kickstart-python |nvim-kickstart-python-nvim-kickstart-python|
7 | - Motivation |nvim-kickstart-python-nvim-kickstart-python-motivation|
8 | - Philosophy & Features|nvim-kickstart-python-nvim-kickstart-python-philosophy-&-features|
9 | - Recommendation|nvim-kickstart-python-nvim-kickstart-python-recommendation|
10 | - Download |nvim-kickstart-python-nvim-kickstart-python-download|
11 | - Syntax Highlighting|nvim-kickstart-python-nvim-kickstart-python-syntax-highlighting|
12 | - Additional plugins of interest|nvim-kickstart-python-nvim-kickstart-python-additional-plugins-of-interest|
13 | - Recommended Citation|nvim-kickstart-python-nvim-kickstart-python-recommended-citation|
14 | - Credits |nvim-kickstart-python-nvim-kickstart-python-credits|
15 |
16 | ==============================================================================
17 | 1. nvim-kickstart-python *nvim-kickstart-python-nvim-kickstart-python*
18 |
19 | A launch point for your nvim config for python.
20 |
21 | Similar to kickstart.nvim , but
22 | specifically for python.
23 |
24 | - |nvim-kickstart-python-motivation|
25 | - |nvim-kickstart-python-philosophy-&-features|
26 | - |nvim-kickstart-python-recommendation|
27 | - |nvim-kickstart-python-download|
28 | - |nvim-kickstart-python-syntax-highlighting|
29 | - |nvim-kickstart-python-additional-plugins-of-interest|
30 | - |nvim-kickstart-python-recommended-citation|
31 | - |nvim-kickstart-python-credits|
32 |
33 |
34 | MOTIVATION *nvim-kickstart-python-nvim-kickstart-python-motivation*
35 |
36 | While there are quite a few great nvim distros and nvim starter configs out
37 | there, one thing I somewhat missed was a base config for specific languages. I
38 | recently started to learn python and was missing a minimal example what the
39 | state-of-the-art nvim setup specifically for python is.
40 |
41 | After figuring most of it out, I decided to publish this config for others to
42 | use. It is intended as a launch point for python devs switching to nvim, or as
43 | a reference for nvim users who want to start doing python development.
44 |
45 |
46 | PHILOSOPHY & FEATURES*nvim-kickstart-python-nvim-kickstart-python-philosophy-&-features*
47 |
48 | - This is not a nvim distro, this is a _minimal_ nvim config specifically for
49 | python. It’s intended as a starting point for creating your own config.
50 | - Requirement: nvim 0.10.
51 | - ~15 plugins, ~350 lines, everything in one single file.
52 | - Includes detailed comments explaining what the config does.
53 | - The config can be fully bootstrapped: all plugins and tools are automatically
54 | installed on startup.
55 | - Uses the current state-of-the-art of the nvim plugin ecosystem.
56 | - Includes some common tooling for python development:
57 | - LSP (Completion, Typing): `pyright`
58 | - Linting (Diagnostics): `ruff`
59 | - Debugger: `debugpy`
60 | - Embedded REPL: `ipython` (if not installed, falls back to `python3`)
61 | - In addition, this config includes editing utilities specifically for python,
62 | like for example docstrings creation, selecting virtual environments, or
63 | auto-converting f-strings.
64 |
65 |
66 | RECOMMENDATION *nvim-kickstart-python-nvim-kickstart-python-recommendation*
67 |
68 | Go through the kickstart-python.lua <./kickstart-python.lua>, it is commented
69 | in detail.
70 |
71 | You can copypaste the config into you current `init.lua` to use it as a
72 | starting point for your regular config, or you can copypaste parts of it into
73 | your existing config.
74 |
75 |
76 | DOWNLOAD *nvim-kickstart-python-nvim-kickstart-python-download*
77 |
78 | `kickstart-python` requires at least nvim 0.10.
79 |
80 | Download the kickstart-python.lua <./kickstart-python.lua> file and run Neovim
81 | with it:
82 |
83 | >bash
84 | # download the config
85 | curl --remote-name "https://raw.githubusercontent.com/chrisgrieser/nvim-kickstart-python/main/kickstart-python.lua"
86 |
87 | # start neovim with the config, opening a file `foobar.py`
88 | # (any existing config you are using remains untouched)
89 | nvim -u kickstart-python.lua foobar.py
90 | <
91 |
92 | The config automatically installs all the plugins and tooling needed.
93 |
94 |
95 | SYNTAX HIGHLIGHTING*nvim-kickstart-python-nvim-kickstart-python-syntax-highlighting*
96 |
97 | Is provided by the nvim-treesitter
98 | plugin and/or the semshi
99 | plugin. The latter requires `pynvim`
100 | (`python3 -m pip install pynvim`) to be installed.
101 |
102 | Both provide better highlighting, Treesitter is considered the more "modern"
103 | approach. Treesitter covers some cases `semshi` does not and vice versa. Have a
104 | look at the comparison <./treesitter-or-semshi.md> to decide for yourself which
105 | one to use. The config uses Treesitter as the more modern approach.
106 |
107 |
108 | ADDITIONAL PLUGINS OF INTEREST*nvim-kickstart-python-nvim-kickstart-python-additional-plugins-of-interest*
109 |
110 | These plugins are not included in the config, but they are worth mentioning, as
111 | some people might be interested in them: - nvim-various-textobjs
112 |
113 | variousindentation-based text objects - NotebookNavigator
114 | JupyterNotebook
115 | emulation - magma.nvim Jupyter
116 | Notebook integration - ropify.nvim `ropify`
117 | integration - nvim-conda `conda`
118 | environment selector - nvim-lspimport
119 | Automatically resolves imports
120 | for `pyright`. - jupytext.nvim
121 | Convert Jupyter Notebooks to
122 | code and back. - py-requirements.nvim
123 | Helpsmanage
124 | python requirements. - venv-selector
125 | switch virtual
126 | environments - python-import
127 |
128 |
129 | RECOMMENDED CITATION*nvim-kickstart-python-nvim-kickstart-python-recommended-citation*
130 |
131 | You can cite this software project as:
132 |
133 | >txt
134 | Grieser, C. (2023). nvim-kickstart-python [Computer software].
135 | https://github.com/chrisgrieser/nvim-kickstart-python
136 | <
137 |
138 |
139 | CREDITS *nvim-kickstart-python-nvim-kickstart-python-credits*
140 |
141 | kickstart.nvim as an example how
142 | to do this.
143 |
144 | In my day job, I am a sociologist studying the social mechanisms underlying the
145 | digital economy. For my PhD project, I investigate the governance of the app
146 | economy and how software ecosystems manage the tension between innovation and
147 | compatibility. If you are interested in this subject, feel free to get in
148 | touch.
149 |
150 | - Website
151 | - Mastodon
152 | - ResearchGate
153 | - LinkedIn
154 |
155 |
156 |
157 | Generated by panvimdoc
158 |
159 | vim:tw=78:ts=8:noet:ft=help:norl:
160 |
--------------------------------------------------------------------------------
/kickstart-python.lua:
--------------------------------------------------------------------------------
1 | -- BOOTSTRAP the plugin manager `lazy.nvim` https://lazy.folke.io/installation
2 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
3 | local lazyLocallyAvailable = vim.uv.fs_stat(lazypath) ~= nil
4 | if not lazyLocallyAvailable then
5 | local lazyrepo = "https://github.com/folke/lazy.nvim.git"
6 | local out = vim.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }):wait()
7 | if out.code ~= 0 then
8 | vim.api.nvim_echo({
9 | { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
10 | { out, "WarningMsg" },
11 | { "\nPress any key to exit..." },
12 | }, true, {})
13 | vim.fn.getchar()
14 | os.exit(1)
15 | end
16 | end
17 | vim.opt.rtp:prepend(lazypath)
18 |
19 | --------------------------------------------------------------------------------
20 |
21 | -- define what key is used for ``. Here, we use `,`.
22 | -- (`:help mapleader` for information what the leader key is)
23 | vim.g.mapleader = ","
24 |
25 | local plugins = {
26 | -- TOOLING: COMPLETION, DIAGNOSTICS, FORMATTING
27 |
28 | -- MASON
29 | -- * Manager for external tools (LSPs, linters, debuggers, formatters)
30 | -- * auto-install those external tools
31 | {
32 | "WhoIsSethDaniel/mason-tool-installer.nvim",
33 | dependencies = {
34 | { "williamboman/mason.nvim", opts = true },
35 | { "williamboman/mason-lspconfig.nvim", opts = true },
36 | },
37 | opts = {
38 | ensure_installed = {
39 | "pyright", -- LSP for python
40 | "ruff", -- linter & formatter (includes flake8, pep8, black, isort, etc.)
41 | "debugpy", -- debugger
42 | "taplo", -- LSP for toml (e.g., for pyproject.toml files)
43 | },
44 | },
45 | },
46 |
47 | -- Setup the LSPs
48 | -- `gd` and `gr` for goto definition / references
49 | -- `` for formatting
50 | -- `c` for code actions (organize imports, etc.)
51 | {
52 | "neovim/nvim-lspconfig",
53 | keys = {
54 | { "gd", vim.lsp.buf.definition, desc = "Goto Definition" },
55 | { "gr", vim.lsp.buf.references, desc = "Goto References" },
56 | { "c", vim.lsp.buf.code_action, desc = "Code Action" },
57 | { "", vim.lsp.buf.format, desc = "Format File" },
58 | },
59 | init = function()
60 | -- this snippet enables auto-completion
61 | local lspCapabilities = vim.lsp.protocol.make_client_capabilities()
62 | lspCapabilities.textDocument.completion.completionItem.snippetSupport = true
63 |
64 | -- setup pyright with completion capabilities
65 | require("lspconfig").pyright.setup({
66 | capabilities = lspCapabilities,
67 | })
68 |
69 | -- setup taplo with completion capabilities
70 | require("lspconfig").taplo.setup({
71 | capabilities = lspCapabilities,
72 | })
73 |
74 | -- ruff uses an LSP proxy, therefore it needs to be enabled as if it
75 | -- were a LSP. In practice, ruff only provides linter-like diagnostics
76 | -- and some code actions, and is not a full LSP yet.
77 | require("lspconfig").ruff.setup({
78 | -- disable ruff as hover provider to avoid conflicts with pyright
79 | on_attach = function(client) client.server_capabilities.hoverProvider = false end,
80 | })
81 | end,
82 | },
83 |
84 | -- COMPLETION
85 | {
86 | "saghen/blink.cmp",
87 | version = "v0.*", -- blink.cmp requires a release tag for its rust binary
88 |
89 | opts = {
90 | -- 'default' for mappings similar to built-in vim completion
91 | -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
92 | -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
93 | keymap = { preset = "default" },
94 |
95 | highlight = {
96 | -- sets the fallback highlight groups to nvim-cmp's highlight groups
97 | -- useful for when your theme doesn't support blink.cmp
98 | use_nvim_cmp_as_default = true,
99 | },
100 | -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
101 | -- adjusts spacing to ensure icons are aligned
102 | nerd_font_variant = "mono",
103 | },
104 | },
105 |
106 | -----------------------------------------------------------------------------
107 | -- PYTHON REPL
108 | -- A basic REPL that opens up as a horizontal split
109 | -- * use `i` to toggle the REPL
110 | -- * use `I` to restart the REPL
111 | -- * `+` serves as the "send to REPL" operator. That means we can use `++`
112 | -- to send the current line to the REPL, and `+j` to send the current and the
113 | -- following line to the REPL, like we would do with other vim operators.
114 | {
115 | "Vigemus/iron.nvim",
116 | keys = {
117 | { "i", vim.cmd.IronRepl, desc = " Toggle REPL" },
118 | { "I", vim.cmd.IronRestart, desc = " Restart REPL" },
119 |
120 | -- these keymaps need no right-hand-side, since that is defined by the
121 | -- plugin config further below
122 | { "+", mode = { "n", "x" }, desc = " Send-to-REPL Operator" },
123 | { "++", desc = " Send Line to REPL" },
124 | },
125 |
126 | -- since irons's setup call is `require("iron.core").setup`, instead of
127 | -- `require("iron").setup` like other plugins would do, we need to tell
128 | -- lazy.nvim which module to via the `main` key
129 | main = "iron.core",
130 |
131 | opts = {
132 | keymaps = {
133 | send_line = "++",
134 | visual_send = "+",
135 | send_motion = "+",
136 | },
137 | config = {
138 | -- This defines how the repl is opened. Here, we set the REPL window
139 | -- to open in a horizontal split to the bottom, with a height of 10.
140 | repl_open_cmd = "horizontal bot 10 split",
141 |
142 | -- This defines which binary to use for the REPL. If `ipython` is
143 | -- available, it will use `ipython`, otherwise it will use `python3`.
144 | -- since the python repl does not play well with indents, it's
145 | -- preferable to use `ipython` or `bypython` here.
146 | -- (see: https://github.com/Vigemus/iron.nvim/issues/348)
147 | repl_definition = {
148 | python = {
149 | command = function()
150 | local ipythonAvailable = vim.fn.executable("ipython") == 1
151 | local binary = ipythonAvailable and "ipython" or "python3"
152 | return { binary }
153 | end,
154 | },
155 | },
156 | },
157 | },
158 | },
159 |
160 | -----------------------------------------------------------------------------
161 | -- SYNTAX HIGHLIGHTING & COLORSCHEME
162 |
163 | -- treesitter for syntax highlighting
164 | -- * auto-installs the parser for python
165 | {
166 | "nvim-treesitter/nvim-treesitter",
167 | -- automatically update the parsers with every new release of treesitter
168 | build = ":TSUpdate",
169 |
170 | -- since treesitter's setup call is `require("nvim-treesitter.configs").setup`,
171 | -- instead of `require("nvim-treesitter").setup` like other plugins do, we
172 | -- need to tell lazy.nvim which module to via the `main` key
173 | main = "nvim-treesitter.configs",
174 |
175 | opts = {
176 | highlight = { enable = true }, -- enable treesitter syntax highlighting
177 | indent = { enable = true }, -- better indentation behavior
178 | ensure_installed = {
179 | -- auto-install the Treesitter parser for python and related languages
180 | "python",
181 | "toml",
182 | "rst",
183 | "ninja",
184 | "markdown",
185 | "markdown_inline",
186 | },
187 | },
188 | },
189 |
190 | -- COLORSCHEME
191 | -- In neovim, the choice of color schemes is unfortunately not purely
192 | -- aesthetic – treesitter-based highlighting or newer features like semantic
193 | -- highlighting are not always supported by a color scheme. It's therefore
194 | -- recommended to use one of the popular, and actively maintained ones to get
195 | -- the best syntax highlighting experience:
196 | -- https://dotfyle.com/neovim/colorscheme/top
197 | {
198 | "folke/tokyonight.nvim",
199 | -- ensure that the color scheme is loaded at the very beginning
200 | priority = 1000,
201 | -- enable the colorscheme
202 | config = function() vim.cmd.colorscheme("tokyonight") end,
203 | },
204 |
205 | -----------------------------------------------------------------------------
206 | -- DEBUGGING
207 |
208 | -- DAP Client for nvim
209 | -- * start the debugger with `dc`
210 | -- * add breakpoints with `db`
211 | -- * terminate the debugger `dt`
212 | {
213 | "mfussenegger/nvim-dap",
214 | keys = {
215 | {
216 | "dc",
217 | function() require("dap").continue() end,
218 | desc = "Start/Continue Debugger",
219 | },
220 | {
221 | "db",
222 | function() require("dap").toggle_breakpoint() end,
223 | desc = "Add Breakpoint",
224 | },
225 | {
226 | "dt",
227 | function() require("dap").terminate() end,
228 | desc = "Terminate Debugger",
229 | },
230 | },
231 | },
232 |
233 | -- UI for the debugger
234 | -- * the debugger UI is also automatically opened when starting/stopping the debugger
235 | -- * toggle debugger UI manually with `du`
236 | {
237 | "rcarriga/nvim-dap-ui",
238 | dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
239 | keys = {
240 | {
241 | "du",
242 | function() require("dapui").toggle() end,
243 | desc = "Toggle Debugger UI",
244 | },
245 | },
246 | -- automatically open/close the DAP UI when starting/stopping the debugger
247 | config = function()
248 | local listener = require("dap").listeners
249 | listener.after.event_initialized["dapui_config"] = function() require("dapui").open() end
250 | listener.before.event_terminated["dapui_config"] = function() require("dapui").close() end
251 | listener.before.event_exited["dapui_config"] = function() require("dapui").close() end
252 | end,
253 | },
254 |
255 | -- Configuration for the python debugger
256 | -- * configures debugpy for us
257 | -- * uses the debugpy installation from mason
258 | {
259 | "mfussenegger/nvim-dap-python",
260 | dependencies = "mfussenegger/nvim-dap",
261 | config = function()
262 | -- fix: E5108: Error executing lua .../Local/nvim-data/lazy/nvim-dap-ui/lua/dapui/controls.lua:14: attempt to index local 'element' (a nil value)
263 | -- see: https://github.com/rcarriga/nvim-dap-ui/issues/279#issuecomment-1596258077
264 | require("dapui").setup()
265 | -- uses the debugypy installation by mason
266 | local debugpyPythonPath = require("mason-registry").get_package("debugpy"):get_install_path()
267 | .. "/venv/bin/python3"
268 | require("dap-python").setup(debugpyPythonPath, {}) ---@diagnostic disable-line: missing-fields
269 | end,
270 | },
271 |
272 | -----------------------------------------------------------------------------
273 | -- EDITING SUPPORT PLUGINS
274 | -- some plugins that help with python-specific editing operations
275 |
276 | -- Docstring creation
277 | -- * quickly create docstrings via `a`
278 | {
279 | "danymat/neogen",
280 | opts = true,
281 | keys = {
282 | {
283 | "a",
284 | function() require("neogen").generate() end,
285 | desc = "Add Docstring",
286 | },
287 | },
288 | },
289 |
290 | -- f-strings
291 | -- * auto-convert strings to f-strings when typing `{}` in a string
292 | -- * also auto-converts f-strings back to regular strings when removing `{}`
293 | {
294 | "chrisgrieser/nvim-puppeteer",
295 | dependencies = "nvim-treesitter/nvim-treesitter",
296 | },
297 | }
298 |
299 | --------------------------------------------------------------------------------
300 |
301 | -- tell lazy.nvim to load and configure all the plugins
302 | require("lazy").setup(plugins)
303 |
304 | --------------------------------------------------------------------------------
305 | -- SETUP BASIC PYTHON-RELATED OPTIONS
306 |
307 | -- The filetype-autocmd runs a function when opening a file with the filetype
308 | -- "python". This method allows you to make filetype-specific configurations. In
309 | -- there, you have to use `opt_local` instead of `opt` to limit the changes to
310 | -- just that buffer. (As an alternative to using an autocmd, you can also put those
311 | -- configurations into a file `/after/ftplugin/{filetype}.lua` in your
312 | -- nvim-directory.)
313 | vim.api.nvim_create_autocmd("FileType", {
314 | pattern = "python", -- filetype for which to run the autocmd
315 | callback = function()
316 | -- use pep8 standards
317 | vim.opt_local.expandtab = true
318 | vim.opt_local.shiftwidth = 4
319 | vim.opt_local.tabstop = 4
320 | vim.opt_local.softtabstop = 4
321 |
322 | -- folds based on indentation https://neovim.io/doc/user/fold.html#fold-indent
323 | -- if you are a heavy user of folds, consider using `nvim-ufo`
324 | vim.opt_local.foldmethod = "indent"
325 |
326 | local iabbrev = function(lhs, rhs) vim.keymap.set("ia", lhs, rhs, { buffer = true }) end
327 | -- automatically capitalize boolean values. Useful if you come from a
328 | -- different language, and lowercase them out of habit.
329 | iabbrev("true", "True")
330 | iabbrev("false", "False")
331 |
332 | -- we can also fix other habits we might have from other languages
333 | iabbrev("--", "#")
334 | iabbrev("null", "None")
335 | iabbrev("none", "None")
336 | iabbrev("nil", "None")
337 | iabbrev("function", "def")
338 | end,
339 | })
340 |
--------------------------------------------------------------------------------
/treesitter-or-semshi.md:
--------------------------------------------------------------------------------
1 | # Treesitter or Semshi
2 |
3 | | neither | Treesitter |
4 | |------------------------------------------------|-----------------------------------------------------------|
5 | |  |  |
6 |
7 | | Semshi | both |
8 | |---------------------------------------------------|------------------------------------------|
9 | |  |  |
10 |
--------------------------------------------------------------------------------
/treesitter-vs-semshi/both.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrisgrieser/nvim-kickstart-python/dc00908e892d26c707c5137345e81a0899a9d0c4/treesitter-vs-semshi/both.png
--------------------------------------------------------------------------------
/treesitter-vs-semshi/neither.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrisgrieser/nvim-kickstart-python/dc00908e892d26c707c5137345e81a0899a9d0c4/treesitter-vs-semshi/neither.png
--------------------------------------------------------------------------------
/treesitter-vs-semshi/semshi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrisgrieser/nvim-kickstart-python/dc00908e892d26c707c5137345e81a0899a9d0c4/treesitter-vs-semshi/semshi.png
--------------------------------------------------------------------------------
/treesitter-vs-semshi/treesitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chrisgrieser/nvim-kickstart-python/dc00908e892d26c707c5137345e81a0899a9d0c4/treesitter-vs-semshi/treesitter.png
--------------------------------------------------------------------------------