diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-01-03 03:05:10 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-01-06 21:19:05 +0900 |
| commit | fe0fb3147b36cbe486e2fcb64a9861e4d8f92064 (patch) | |
| tree | d708c00a3b6500d8b4b9dd533d71ea6fc71bedb1 | |
| parent | d0ebe31c0128893644c7e8cc3faa407b301fefac (diff) | |
| download | dotfiles-fe0fb3147b36cbe486e2fcb64a9861e4d8f92064.tar.gz dotfiles-fe0fb3147b36cbe486e2fcb64a9861e4d8f92064.tar.zst dotfiles-fe0fb3147b36cbe486e2fcb64a9861e4d8f92064.zip | |
nvim: fix PHP indent
| -rw-r--r-- | .config/nvim/after/indent/php.lua | 8 | ||||
| -rw-r--r-- | .config/nvim/lua/vimrc/init.lua | 13 |
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 {} |
