htmldjango highlight changes, ruff args, lsp zero config

This commit is contained in:
2023-02-06 07:07:52 -06:00
parent 167589deb1
commit da374365c8
7 changed files with 462 additions and 475 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ opt.mouse = ""
vim.cmd([[hi CursorLine cterm=NONE ctermbg=darkgray ctermfg=white]]) vim.cmd([[hi CursorLine cterm=NONE ctermbg=darkgray ctermfg=white]])
vim.cmd([[au BufRead,BufNewFile .env.* set filetype=sh]]) vim.cmd([[au BufRead,BufNewFile .env.* set filetype=sh]])
vim.cmd([[au BufRead,BufNewFile Dockerfile.* set filetype=dockerfile]]) vim.cmd([[au BufRead,BufNewFile Dockerfile.* set filetype=dockerfile]])
--vim.cmd([[au BufRead,BufNewFile *.html set filetype=html]]) vim.cmd([[au BufRead,BufNewFile *.html set filetype=html]])
-- redo folds on write -- redo folds on write
vim.cmd([[au BufWrite * normal zx]]) vim.cmd([[au BufWrite * normal zx]])
+40 -15
View File
@@ -213,7 +213,7 @@ function M.nvim_treesitter()
disable = function(lang, bufnr) disable = function(lang, bufnr)
return highlight_disable[lang] or too_many_lines(bufnr) return highlight_disable[lang] or too_many_lines(bufnr)
end, end,
additional_vim_regex_highlighting = { "htmldjango" }, --additional_vim_regex_highlighting = { "htmldjango", "html" },
}, },
rainbow = { rainbow = {
enable = true, enable = true,
@@ -224,7 +224,7 @@ function M.nvim_treesitter()
max_file_lines = nil, max_file_lines = nil,
}, },
indent = { indent = {
enable = false, enable = true,
}, },
}) })
@@ -240,15 +240,15 @@ function M.nvim_treesitter()
local parser_config = require("nvim-treesitter.parsers").get_parser_configs() local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.htmldjango = { parser_config.htmldjango = {
install_info = { install_info = {
url = htmldjango_path, -- local path or git repo url = htmldjango_path,
files = { "src/parser.c" }, files = { "src/parser.c" },
-- optional entries: requires_generate_from_grammar = true,
--branch = "paired-tags", -- default branch in case of git repo if different from master
--generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = true, -- if folder contains pre-generated src/parser.c
}, },
filetype = "html", -- if filetype does not match the parser name filetype = "html",
} }
local ft_to_parser = require("nvim-treesitter.parsers").filetype_to_parsername
ft_to_parser.html = "htmldjango"
end end
end end
@@ -258,6 +258,15 @@ function M.nvim_lspconfig()
signs = true, signs = true,
update_in_insert = false, update_in_insert = false,
}) })
local lspconfig = require("lspconfig")
lspconfig.tailwindcss.setup({
init_options = {
userLanguages = {
htmldjango = "html",
},
},
})
end end
function M.nvim_lsp_installer() function M.nvim_lsp_installer()
@@ -378,12 +387,14 @@ function M.null_ls()
-- ORDER IN TABLE DETERMINES EXECUTION ORDER -- ORDER IN TABLE DETERMINES EXECUTION ORDER
local sources = { local sources = {
-- python -- python
--null_ls.builtins.diagnostics.flake8,
null_ls.builtins.diagnostics.mypy, null_ls.builtins.diagnostics.mypy,
null_ls.builtins.diagnostics.ruff, null_ls.builtins.diagnostics.ruff,
null_ls.builtins.formatting.black, null_ls.builtins.formatting.black,
null_ls.builtins.formatting.ruff, null_ls.builtins.formatting.ruff.with({
extra_args = { "--extend-select", "I001", "--unfixable", "F841,F842,F401" },
}),
--null_ls.builtins.formatting.isort, --null_ls.builtins.formatting.isort,
--null_ls.builtins.diagnostics.flake8,
--null_ls.builtins.diagnostics.djlint, --null_ls.builtins.diagnostics.djlint,
-- js -- js
@@ -392,12 +403,15 @@ function M.null_ls()
null_ls.builtins.formatting.prettier.with({ null_ls.builtins.formatting.prettier.with({
extra_filetypes = { "svelte" }, extra_filetypes = { "svelte" },
}), }),
-- lua -- lua
null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.stylua,
-- bash -- bash
null_ls.builtins.formatting.shfmt, null_ls.builtins.formatting.shfmt,
null_ls.builtins.diagnostics.shellcheck, null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.code_actions.shellcheck, null_ls.builtins.code_actions.shellcheck,
-- cpp -- cpp
null_ls.builtins.formatting.clang_format, null_ls.builtins.formatting.clang_format,
} }
@@ -405,15 +419,11 @@ function M.null_ls()
sources = sources, sources = sources,
on_attach = config.on_attach, on_attach = config.on_attach,
root_dir = config.root_dir, root_dir = config.root_dir,
-- removed error "warning: multiple different client offset_encodings detected for buffer, this is not supported yet"
--on_init = function(client, _)
-- client.offset_encoding = "utf-32"
--end,
}) })
end end
function M.nvim_autopairs() function M.nvim_autopairs()
require("nvim-autopairs").setup({ check_ts = true }) require("nvim-autopairs").setup({ check_ts = false, enable_moveright = false })
end end
function M.nvim_cmp() function M.nvim_cmp()
@@ -471,4 +481,19 @@ function M.gitsigns()
require("gitsigns").setup() require("gitsigns").setup()
end end
function M.lsp_zero()
--
-- https://github.com/VonHeikemen/lsp-zero.nvim
--
-- Learn the keybindings, see :help lsp-zero-keybindings
-- Learn to configure LSP servers, see :help lsp-zero-api-showcase
local lsp = require("lsp-zero")
lsp.preset("recommended")
-- (Optional) Configure lua language server for neovim
lsp.nvim_workspace()
lsp.setup()
end
return M return M
+5 -4
View File
@@ -10,14 +10,15 @@ config.harpoon()
config.hop() config.hop()
config.indent_blankline() config.indent_blankline()
config.lualine() config.lualine()
config.null_ls()
config.nvim_autopairs() config.nvim_autopairs()
config.nvim_cmp() --config.nvim_cmp()
config.nvim_fzf() config.nvim_fzf()
config.nvim_lsp_installer() --config.nvim_lsp_installer()
config.nvim_lspconfig()
config.nvim_treesitter() config.nvim_treesitter()
--config.onedark() --config.onedark()
config.rnvimr() config.rnvimr()
config.tokyonight() config.tokyonight()
config.gitsigns() config.gitsigns()
--config.nvim_lspconfig()
config.lsp_zero()
config.null_ls()
+33 -9
View File
@@ -17,6 +17,7 @@ require("packer").startup(function(use)
-- SESSION -- SESSION
use("ThePrimeagen/harpoon") use("ThePrimeagen/harpoon")
use("nvim-lua/plenary.nvim")
use("rmagatti/auto-session") use("rmagatti/auto-session")
use("mbbill/undotree") use("mbbill/undotree")
@@ -33,8 +34,8 @@ require("packer").startup(function(use)
}) })
-- SNIPPETS -- SNIPPETS
use("SirVer/ultisnips") --use("SirVer/ultisnips")
use("honza/vim-snippets") --use("honza/vim-snippets")
--use("L3MON4D3/LuaSnip") -- Snippets plugin --use("L3MON4D3/LuaSnip") -- Snippets plugin
-- LSP -- LSP
@@ -45,17 +46,40 @@ require("packer").startup(function(use)
}) })
use("nvim-treesitter/nvim-treesitter-context") use("nvim-treesitter/nvim-treesitter-context")
use("nvim-treesitter/playground") use("nvim-treesitter/playground")
use("neovim/nvim-lspconfig")
use("williamboman/nvim-lsp-installer")
use("nvim-lua/plenary.nvim")
use("jose-elias-alvarez/nvim-lsp-ts-utils")
use("jose-elias-alvarez/null-ls.nvim") use("jose-elias-alvarez/null-ls.nvim")
use("windwp/nvim-autopairs") use("windwp/nvim-autopairs")
--use("neovim/nvim-lspconfig")
--use("williamboman/nvim-lsp-installer")
--use("jose-elias-alvarez/nvim-lsp-ts-utils")
--use({
-- "hrsh7th/cmp-nvim-lsp",
-- requires = "quangnguyen30192/cmp-nvim-ultisnips",
--})
--use("hrsh7th/nvim-cmp")
use({ use({
"hrsh7th/cmp-nvim-lsp", "VonHeikemen/lsp-zero.nvim",
requires = "quangnguyen30192/cmp-nvim-ultisnips", branch = "v1.x",
requires = {
-- LSP Support
{ "neovim/nvim-lspconfig" }, -- Required
{ "williamboman/mason.nvim" }, -- Optional
{ "williamboman/mason-lspconfig.nvim" }, -- Optional
-- Autocompletion
{ "hrsh7th/nvim-cmp" }, -- Required
{ "hrsh7th/cmp-nvim-lsp" }, -- Required
{ "hrsh7th/cmp-buffer" }, -- Optional
{ "hrsh7th/cmp-path" }, -- Optional
{ "saadparwaiz1/cmp_luasnip" }, -- Optional
{ "hrsh7th/cmp-nvim-lua" }, -- Optional
-- Snippets
{ "L3MON4D3/LuaSnip" }, -- Required
{ "rafamadriz/friendly-snippets" }, -- Optional
},
}) })
use("hrsh7th/nvim-cmp")
-- JS -- JS
use("HerringtonDarkholme/yats.vim") use("HerringtonDarkholme/yats.vim")
+5 -70
View File
@@ -3,77 +3,16 @@
;[ ;[
; "<" ; "<"
; "/>"
; ">" ; ">"
; "</" ; "</"
; "/>"
;] @punctuation.bracket ;] @punctuation.bracket
;] @constant
(doctype) @comment (doctype) @comment
((tag_name) @type (#match? @type "^(head|body)$")) ((attribute_name) @parameter
(#lua-match? @parameter "^up[-]%l+$"))
((tag_name) @comment (#eq? @comment "html"))
;(element (start_tag ((tag_name) @function) (#eq? @function "template")))
;(element (end_tag ((tag_name) @function) (#eq? @function "template")))
;(attribute_name) @constant
;(element
; (start_tag
; ((tag_name) @function)
; (attribute (attribute_name) @_alpine))
; (#lua-match? @_alpine "^[@:]%l+.-$"))
;
;(element
; (start_tag
; (attribute (attribute_name) @_alpine))
; (end_tag ((tag_name) @function))
; (#lua-match? @_alpine "^[@:]%l+.-$"))
;
;(element
; (start_tag
; ((tag_name) @function)
; (attribute (attribute_name) @_alpine))
; (#lua-match? @_alpine "^x[-]%l+$"))
;
;(element
; (start_tag
; (attribute (attribute_name) @_alpine))
; (end_tag ((tag_name) @function))
; (#lua-match? @_alpine "^x[-]%l+$"))
;
;(element
; (self_closing_tag
; ((tag_name) @function)
; (attribute (attribute_name) @_alpine))
; (#lua-match? @_alpine "^[@:]%l+.-$"))
;
;(element
; (self_closing_tag
; ((tag_name) @function)
; (attribute (attribute_name) @_alpine))
; (#lua-match? @_alpine "^x[-]%l+$"))
;
;(element
; (start_tag
; (attribute (attribute_name) @parameter))
; (#lua-match? @parameter "^[@:]%l+.-$"))
;
;(element
; (start_tag
; (attribute (attribute_name) @parameter))
; (#lua-match? @parameter "^x[-]%l+$"))
;
;(element
; (self_closing_tag
; (attribute (attribute_name) @parameter))
; (#lua-match? @parameter "^[@:]%l+.-$"))
;
;(element
; (self_closing_tag
; (attribute (attribute_name) @parameter))
; (#lua-match? @parameter "^x[-]%l+$"))
((attribute_name) @parameter ((attribute_name) @parameter
(#lua-match? @parameter "^x[-]%l+$")) (#lua-match? @parameter "^x[-]%l+$"))
@@ -81,6 +20,7 @@
((attribute_name) @parameter ((attribute_name) @parameter
(#lua-match? @parameter "^[@:]%l+.-$")) (#lua-match? @parameter "^[@:]%l+.-$"))
; colors regular variables in strings with tokyonight theme
((attribute ((attribute
(attribute_name) @_alpine (attribute_name) @_alpine
(quoted_attribute_value (attribute_value) @operator)) (quoted_attribute_value (attribute_value) @operator))
@@ -90,8 +30,3 @@
(attribute_name) @_alpine (attribute_name) @_alpine
(quoted_attribute_value (attribute_value) @operator)) (quoted_attribute_value (attribute_value) @operator))
(#lua-match? @_alpine "^x[-]%l+$")) (#lua-match? @_alpine "^x[-]%l+$"))
[
"endfor"
"endif"
] @keyword
+7 -7
View File
@@ -11,11 +11,11 @@
(script_element (script_element
(raw_text) @javascript) (raw_text) @javascript)
((text) @htmldjango (#lua-match? @htmldjango "^{%p%s+%l+.-%s+%p}$")) ;((text) @htmldjango (#lua-match? @htmldjango "^{%p%s+%l+.-%s+%p}$"))
;
((text) @htmldjango (#lua-match? @htmldjango "^{{%s+.-%s+}}$")) ;((text) @htmldjango (#lua-match? @htmldjango "^{{%s+.-%s+}}$"))
;
((attribute ;((attribute
(quoted_attribute_value (attribute_value) @htmldjango)) ; (quoted_attribute_value (attribute_value) @htmldjango))
(#lua-match? @htmldjango "^{{%s+.-%s+}}$")) ; (#lua-match? @htmldjango "^{{%s+.-%s+}}$"))
+2
View File
@@ -40,3 +40,5 @@
"is" "is"
"as" "as"
] @keyword ] @keyword
(content) @html