Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The package provides pre-built wheels with the Rust-based LSP server compiled fo

The Django Language Server works with any editor that supports the Language Server Protocol (LSP). We currently have setup instructions for:

- [Neovim](docs/editor-setup/neovim.md)
- [Neovim](docs/editors/neovim.md)

Got it working in your editor? [Help us add setup instructions!](#testing-and-documenting-editor-setup)

Expand Down
55 changes: 0 additions & 55 deletions docs/editor-setup/neovim.md

This file was deleted.

57 changes: 57 additions & 0 deletions docs/editors/neovim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Neovim
---

# djls.nvim

A Neovim plugin for the Django Language Server.

!!! note

This plugin is a temporary solution until the project is mature enough to be integrated into [mason.nvim](https://github.com/williamboman/mason.nvim) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).

## Installation

### [lazy.nvim](https://github.com/folke/lazy.nvim)

Minimal setup:

```lua
{
"joshuadavidthomas/django-language-server",
}
```

The plugin takes advantage of lazy.nvim's spec loading by providing a `lazy.lua` at the root of the repository to handle setup and runtime path configuration automatically. This handles adding the plugin subdirectory to Neovim's runtime path and initializing the LSP client:

```lua
{
"joshuadavidthomas/django-language-server",
dependencies = {
"neovim/nvim-lspconfig",
},
config = function(plugin, opts)
vim.opt.rtp:append(plugin.dir .. "/editors/nvim")
require("djls").setup(opts)
end,
}
```

The spec can also serve as a reference for a more detailed installation if needed or desired.

## Configuration

Default configuration options:

```lua
{
cmd = { "djls", "serve" },
filetypes = { "django-html", "htmldjango", "python" },
root_dir = function(fname)
local util = require("lspconfig.util")
local root = util.root_pattern("manage.py", "pyproject.toml")(fname)
return root or vim.fn.getcwd()
end,
settings = {},
}
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The package provides pre-built wheels with the Rust-based LSP server compiled fo

The Django Language Server works with any editor that supports the Language Server Protocol (LSP). We currently have setup instructions for:

- [Neovim](editor-setup/neovim.md)
- [Neovim](editors/neovim.md)

Got it working in your editor? [Help us add setup instructions!](#testing-and-documenting-editor-setup)

Expand Down
36 changes: 28 additions & 8 deletions docs/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,28 +499,48 @@ def replace_link(match: re.Match[str]) -> str:


def main():
console.print("[bold blue]File Processor[/bold blue]")
"""Process documentation files."""
console.print("[bold blue]Documentation Processor[/bold blue]")

processors = [
add_frontmatter({"title": "Home"}),
common_processors = [
convert_admonitions,
convert_repo_links(
"https://github.com/joshuadavidthomas/django-language-server"
),
]

success = process_file(
readme_success = process_file(
input="README.md",
output="docs/index.md",
processors=processors,
processors=[
add_frontmatter({"title": "Home"}),
*common_processors,
],
preview=True,
description="README.md → docs/index.md",
)

if success:
console.print("\n[green]✨ Processing completed successfully![/green]")
nvim_success = process_file(
input="editors/nvim/README.md",
output="docs/editors/neovim.md",
processors=[
add_frontmatter({"title": "Neovim"}),
*common_processors,
],
preview=True,
description="Neovim docs → docs/editors/neovim.md",
)

if readme_success and nvim_success:
console.print("\n[green]✨ All files processed successfully![/green]")
else:
console.print("\n[red]Processing failed![/red]")
console.print("\n[red]Some files failed to process:[/red]")
for name, success in [
("README.md → docs/index.md", readme_success),
("Neovim docs → docs/editors/neovim.md", nvim_success),
]:
status = "[green]✓[/green]" if success else "[red]✗[/red]"
console.print(f"{status} {name}")


if __name__ == "__main__":
Expand Down
52 changes: 52 additions & 0 deletions editors/nvim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# djls.nvim

A Neovim plugin for the Django Language Server.

> [!NOTE]
> This plugin is a temporary solution until the project is mature enough to be integrated into [mason.nvim](https://github.com/williamboman/mason.nvim) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).

## Installation

### [lazy.nvim](https://github.com/folke/lazy.nvim)

Minimal setup:

```lua
{
"joshuadavidthomas/django-language-server",
}
```

The plugin takes advantage of lazy.nvim's spec loading by providing a `lazy.lua` at the root of the repository to handle setup and runtime path configuration automatically. This handles adding the plugin subdirectory to Neovim's runtime path and initializing the LSP client:

```lua
{
"joshuadavidthomas/django-language-server",
dependencies = {
"neovim/nvim-lspconfig",
},
config = function(plugin, opts)
vim.opt.rtp:append(plugin.dir .. "/editors/nvim")
require("djls").setup(opts)
end,
}
```

The spec can also serve as a reference for a more detailed installation if needed or desired.

## Configuration

Default configuration options:

```lua
{
cmd = { "djls", "serve" },
filetypes = { "django-html", "htmldjango", "python" },
root_dir = function(fname)
local util = require("lspconfig.util")
local root = util.root_pattern("manage.py", "pyproject.toml")(fname)
return root or vim.fn.getcwd()
end,
settings = {},
}
```
27 changes: 27 additions & 0 deletions editors/nvim/lua/djls/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local M = {}

M.defaults = {
cmd = { "djls", "serve" },
filetypes = { "django-html", "htmldjango", "python" },
root_dir = function(fname)
local util = require("lspconfig.util")
local root = util.root_pattern("manage.py", "pyproject.toml")(fname)
return root or vim.fn.getcwd()
end,
settings = {},
}

function M.setup(opts)
opts = vim.tbl_deep_extend("force", M.defaults, opts or {})

local configs = require("lspconfig.configs")
if not configs.djls then
configs.djls = {
default_config = opts,
}
end

require("lspconfig").djls.setup(opts)
end

return M
10 changes: 10 additions & 0 deletions lazy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
"joshuadavidthomas/django-language-server",
dependencies = {
"neovim/nvim-lspconfig",
},
config = function(plugin, opts)
vim.opt.rtp:append(plugin.dir .. "/editors/nvim")
require("djls").setup(opts)
end,
}
Loading