Skip to content

Commit

Permalink
neovim: Fix the indent issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yutkat committed Apr 1, 2024
1 parent e0d2e19 commit 83d11bc
Show file tree
Hide file tree
Showing 8 changed files with 1,780 additions and 1,769 deletions.
10 changes: 5 additions & 5 deletions .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ChatGPT.nvim": { "branch": "main", "commit": "df53728e05129278d6ea26271ec086aa013bed90" },
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"CopilotChat.nvim": { "branch": "canary", "commit": "51ec2b45fed9cb0c8551c94ee2f2fb68de1e970a" },
"LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" },
"LuaSnip": { "branch": "master", "commit": "79cc25c39878401d4e8b6ec42fcf14639426bafc" },
"NeoComposer.nvim": { "branch": "main", "commit": "b06e8e88e289947937f241f76e86f7c46f4a5805" },
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
"browse.nvim": { "branch": "main", "commit": "8292baa12ef4611532526e8a6f7a315848eceb74" },
Expand Down Expand Up @@ -46,7 +46,7 @@
"friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" },
"git-conflict.nvim": { "branch": "main", "commit": "4c8e252b87d54d944c1e56bfb477f78b6fdaf661" },
"git-rebase-auto-diff.nvim": { "branch": "main", "commit": "ad95f18cb85c24ddc0b48bf190bc313dfc58e2d6" },
"gitsigns.nvim": { "branch": "main", "commit": "70584ff9aae8078b64430c574079d79620b8f06d" },
"gitsigns.nvim": { "branch": "main", "commit": "1bb277b41d65f68b091e4ab093f59e68a0def2a6" },
"guess-indent.nvim": { "branch": "main", "commit": "b8ae749fce17aa4c267eec80a6984130b94f80b2" },
"history-ignore.nvim": { "branch": "main", "commit": "fa873a546e739361c1b9dd6019e7504eb57d61f3" },
"hlargs.nvim": { "branch": "main", "commit": "0f2dbf02ff948e8fc8ebe07b215f3174a12bbe3c" },
Expand Down Expand Up @@ -111,7 +111,7 @@
"nvim-test": { "branch": "main", "commit": "e06f3d029ee161f3ead6193cf27354d1eb8723c3" },
"nvim-tree-docs": { "branch": "master", "commit": "5db023d783da1e55339e5e25caaf72a59597e626" },
"nvim-treehopper": { "branch": "master", "commit": "5a28bff46c05d28bdb4bcaef67e046eb915a9390" },
"nvim-treesitter": { "branch": "master", "commit": "c51d50386867c2e04f3b420439985aac985dd8d4" },
"nvim-treesitter": { "branch": "master", "commit": "30492e7e1c9e5af3642e8a74c2f88dc1f50ec305" },
"nvim-treesitter-context": { "branch": "master", "commit": "f19766163c18515fb4d3c12d572bf9cba6cdb990" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "d2a4ffc22d9d38d44edb73da007b3cf43451e9b4" },
Expand All @@ -129,14 +129,14 @@
"peek.nvim": { "branch": "master", "commit": "62e9e46fb5b6be510c60f67c1fd9913764efaac0" },
"plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"portal.nvim": { "branch": "main", "commit": "94ff1d57537e2cdb939a359bf7a7467b21a1defe" },
"portal.nvim": { "branch": "main", "commit": "77d9d53fec945bfa407d5fd7120f1b4f117450ed" },
"possession.nvim": { "branch": "master", "commit": "4665ceec10991e040b7117582e62cc5edd3c964f" },
"put_at_end.nvim": { "branch": "master", "commit": "d885ca16bbc19bbf3abbe06343fe39ed5b8500da" },
"qf_helper.nvim": { "branch": "master", "commit": "91dad029c11d1c39b0d1276eda52616f651072be" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "580bc045c7ab3ab3ebd267774038c0d8cc19c789" },
"registers.nvim": { "branch": "main", "commit": "22bb98f93a423252fffeb3531f7bc12a3e07b63f" },
"replacer.nvim": { "branch": "master", "commit": "32e1713230844fa52f7f0598c59295de3c90dc95" },
"rustaceanvim": { "branch": "master", "commit": "282632145e9ba87b1d4d5367ddad88f9ddecd830" },
"rustaceanvim": { "branch": "master", "commit": "e9db3d53142f8c707eb4a62d01007ce6b02cef56" },
"save-clipboard-on-exit.nvim": { "branch": "main", "commit": "506d6970026e1c2e59a42ecdc7378fe908da8a0b" },
"scrap.nvim": { "branch": "main", "commit": "cc8453ed613932c744c3d1ec42f379b78bd8b92c" },
"sidebar.nvim": { "branch": "main", "commit": "5695712eef6288fff667343c4ae77c54911bdb1b" },
Expand Down
68 changes: 34 additions & 34 deletions .config/nvim/lua/rc/myplugins/start/lastposition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@ local ignore_buftype = { "quickfix", "nofile", "help" }
local ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }

local function run()
if vim.tbl_contains(ignore_buftype, vim.bo.buftype) then
return
end
if vim.tbl_contains(ignore_buftype, vim.bo.buftype) then
return
end

if vim.tbl_contains(ignore_filetype, vim.bo.filetype) then
-- reset cursor to first line
vim.cmd.normal({ [[gg]], bang = true })
return
end
if vim.tbl_contains(ignore_filetype, vim.bo.filetype) then
-- reset cursor to first line
vim.cmd.normal({ [[gg]], bang = true })
return
end

-- If a line has already been specified on the command line, we are done
-- nvim file +num
if vim.fn.line(".") > 1 then
return
end
-- If a line has already been specified on the command line, we are done
-- nvim file +num
if vim.fn.line(".") > 1 then
return
end

local last_line = vim.fn.line([['"]])
local buff_last_line = vim.fn.line("$")
local last_line = vim.fn.line([['"]])
local buff_last_line = vim.fn.line("$")

-- If the last line is set and the less than the last line in the buffer
if last_line > 0 and last_line <= buff_last_line then
local win_last_line = vim.fn.line("w$")
local win_first_line = vim.fn.line("w0")
-- Check if the last line of the buffer is the same as the win
if win_last_line == buff_last_line then
-- Set line to last line edited
vim.cmd.normal({ [[g`"]], bang = true })
-- Try to center
elseif buff_last_line - last_line > ((win_last_line - win_first_line) / 2) - 1 then
vim.cmd[[normal! g`"zz]]
vim.cmd.normal({ [[g`"zz]], bang = true })
else
vim.cmd.normal({ [[G'"<c-e>]], bang = true })
end
end
-- If the last line is set and the less than the last line in the buffer
if last_line > 0 and last_line <= buff_last_line then
local win_last_line = vim.fn.line("w$")
local win_first_line = vim.fn.line("w0")
-- Check if the last line of the buffer is the same as the win
if win_last_line == buff_last_line then
-- Set line to last line edited
vim.cmd.normal({ [[g`"]], bang = true })
-- Try to center
elseif buff_last_line - last_line > ((win_last_line - win_first_line) / 2) - 1 then
vim.cmd [[normal! g`"zz]]
vim.cmd.normal({ [[g`"zz]], bang = true })
else
vim.cmd.normal({ [[G'"<c-e>]], bang = true })
end
end
end

vim.api.nvim_create_autocmd({'BufReadPost', 'BufWinEnter', 'FileType', 'VimEnter'}, {
group = vim.api.nvim_create_augroup('nvim-lastplace', {}),
callback = run
vim.api.nvim_create_autocmd({ 'BufReadPost', 'BufWinEnter', 'FileType', 'VimEnter' }, {
group = vim.api.nvim_create_augroup('nvim-lastplace', {}),
callback = run
})
2 changes: 1 addition & 1 deletion .config/nvim/lua/rc/option.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ vim.g.editorconfig_enable = true
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.softtabstop = 0
vim.o.expandtab = true -- Expand tabs to whitespace characters
-- vim.o.expandtab = true -- Expand tabs to whitespace characters
-- vim.o.autoindent smartindent
vim.o.list = true
vim.o.listchars = "tab:» "
Expand Down
12 changes: 6 additions & 6 deletions .config/nvim/lua/rc/pluginconfig/browse.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
local browse = require("browse")

local function command(name, rhs, opts)
opts = opts or {}
vim.api.nvim_create_user_command(name, rhs, opts)
opts = opts or {}
vim.api.nvim_create_user_command(name, rhs, opts)
end

command("BrowseInputSearch", function()
browse.input_search()
browse.input_search()
end, {})

command("BrowseDevdocsSearch", function()
browse.devdocs.search()
browse.devdocs.search()
end, {})

command("BrowseDevdocsFiletypeSearch", function()
browse.devdocs.search_with_filetype()
browse.devdocs.search_with_filetype()
end, {})

command("BrowseMdnSearch", function()
browse.mdn.search()
browse.mdn.search()
end, {})
16 changes: 9 additions & 7 deletions .config/nvim/lua/rc/pluginconfig/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ require("format").setup({
-- end_pattern = "^}}}$"
-- }
-- },
lua = { { cmd = {
function(file)
return string.format("lua-format -i %s", file)
end,
} } },
lua = { {
cmd = {
function(file)
return string.format("lua-format -i %s", file)
end,
}
} },
-- go = {
-- {
-- cmd = {"gofmt -w", "goimports -w"},
Expand Down Expand Up @@ -55,8 +57,8 @@ vim.api.nvim_set_var("format_file_type", format_file_type)
vim.api.nvim_exec(
[[
augroup vimrc_format
autocmd!
autocmd BufWritePost * if index(g:format_file_type, &filetype) != -1 | execute "FormatWrite" | e | endif
autocmd!
autocmd BufWritePost * if index(g:format_file_type, &filetype) != -1 | execute "FormatWrite" | e | endif
augroup END
]],
true
Expand Down
4 changes: 2 additions & 2 deletions .config/nvim/lua/rc/pluginconfig/harpoon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ vim.cmd([[
highlight HarpoonBorder guibg=#282828 guifg=white
highlight HarpoonWindow guibg=#282828 guifg=white
augroup vimrc_harpoon
autocmd!
autocmd Filetype harpoon nnoremap <buffer><silent> <Esc> <Cmd>lua require("harpoon.cmd-ui").toggle_quick_menu()<CR>
autocmd!
autocmd Filetype harpoon nnoremap <buffer><silent> <Esc> <Cmd>lua require("harpoon.cmd-ui").toggle_quick_menu()<CR>
augroup END
]])
Loading

0 comments on commit 83d11bc

Please sign in to comment.