aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-01-03 03:05:10 +0900
committernsfisis <nsfisis@gmail.com>2024-01-06 21:19:05 +0900
commitfe0fb3147b36cbe486e2fcb64a9861e4d8f92064 (patch)
treed708c00a3b6500d8b4b9dd533d71ea6fc71bedb1
parentd0ebe31c0128893644c7e8cc3faa407b301fefac (diff)
downloaddotfiles-fe0fb3147b36cbe486e2fcb64a9861e4d8f92064.tar.gz
dotfiles-fe0fb3147b36cbe486e2fcb64a9861e4d8f92064.tar.zst
dotfiles-fe0fb3147b36cbe486e2fcb64a9861e4d8f92064.zip
nvim: fix PHP indent
-rw-r--r--.config/nvim/after/indent/php.lua8
-rw-r--r--.config/nvim/lua/vimrc/init.lua13
2 files changed, 21 insertions, 0 deletions
diff --git a/.config/nvim/after/indent/php.lua b/.config/nvim/after/indent/php.lua
new file mode 100644
index 0000000..aeffba8
--- /dev/null
+++ b/.config/nvim/after/indent/php.lua
@@ -0,0 +1,8 @@
+vimrc.after_indent('php', function(conf)
+ -- The default indent plugin for PHP bundled with Neovim disables
+ -- 'smartindent' and 'autoindent' because the plugin fully handles
+ -- indentation by itself. However, I use nvim-treesitter plugin for PHP
+ -- indentation, which requires that these options are on.
+ vim.bo.smartindent = true
+ vim.bo.autoindent = true
+end)
diff --git a/.config/nvim/lua/vimrc/init.lua b/.config/nvim/lua/vimrc/init.lua
index be5eba9..feedd0b 100644
--- a/.config/nvim/lua/vimrc/init.lua
+++ b/.config/nvim/lua/vimrc/init.lua
@@ -30,6 +30,19 @@ end
+function M.after_indent(ft, callback)
+ local var_name = 'did_indent_' .. ft .. '_after'
+ if vim.b[var_name] ~= nil then
+ return
+ end
+
+ callback(conf)
+
+ vim.b[var_name] = true
+end
+
+
+
local function set_indentation(style, width)
local editorconfig = vim.b.editorconfig or {}