Compare commits

...

2 Commits

Author SHA1 Message Date
hedy 2fb9c7d9b4
nvim: All the changes...
Sincere apologies to future self for not documenting atomic changes
2023-11-13 21:36:34 +08:00
hedy 933e6a0671
nvim: Fix treesitter and Ibl problems 2023-11-03 09:09:05 +08:00
11 changed files with 107 additions and 61 deletions

View File

@ -7,7 +7,7 @@
-- `lsp-config` with nvim-0.5
-- `nvim-cmp`
-- Treesitter: context + textobjects
- Status line
- Status line (SUBJECT TO CHANGE)
-- Lualine
- Theme: Tundra
- File explorer: NvimTree

View File

@ -51,8 +51,21 @@ o.shiftwidth = 4 -- Put or remove 4 spaces with using < and >
o.smarttab = true -- Delete spaces at tabstop width
o.copyindent = true -- Copy indentation from previous line
o.hidden = true -- Allows switching to another file while current is unsaved.
o.cmdheight = 0
o.showcmdloc = "last"
-- lualine, feline, galaxyline? RULER + inc-line!
-- Used when there is only one horizontal split
o.rulerformat = "%#LineNr#%20(%f %p%%%)"
-- Needed to show "recording @" and other messages until this issue is resolved
-- in neovim core
o.cmdheight = 1
o.laststatus = 0
vim.api.nvim_set_hl(0, 'Statusline', {link = 'Normal'})
vim.api.nvim_set_hl(0, 'StatuslineNC', {link = 'Normal'})
o.statusline = '%#WinSeparator#'.. (""):rep(vim.api.nvim_win_get_width(0)) .. '%*'
-- Clear cmdline
vim.keymap.set("n", "<leader><leader>", "<cmd>echo<cr>")
-- Show LSP W/E hints on another column next to the line numbers
o.signcolumn = "yes" -- Set to "number" will merge the LSP W/E hints with the number col
@ -71,6 +84,9 @@ o.foldmethod = "expr"
o.foldexpr = "nvim_treesitter#foldexpr()"
o.swapfile = false
-- This is used to control how often to update swap file. Since I don't
-- use swap, I can control CursorHold time with this.
o.updatetime = 3000
o.backup = false
o.undodir = vim.fn.expand("~") .. "/.local/share/nvim/undodir/"
o.undofile = true

View File

@ -7,7 +7,7 @@ if not vim.loop.fs_stat(lazypath) then
})
end
vim.opt.rtp:prepend(lazypath)
vim.opt.completeopt = { "menuone", "noinsert", "noselect", "preview" }
vim.opt.completeopt = { "menu", "noinsert", "noselect", "preview" }
-- Fix when ft = blah included in plugin spec, syntax not loaded.
vim.cmd [[

View File

@ -21,6 +21,8 @@ map("n", "<Leader>p", "\"+p", d "System clipboard paste")
map("n", "<Leader>rg", "<cmd>registers<CR>", d "Show registers, also <leader>fR")
map("n", "<leader>u", "gul")
map("n", "<leader>U", "gUl")
map("n", "<leader><down>", "<cmd><down>")
map("n", "<leader><up>", "<cmd><up>")
-----------------------------------
-- Normal and Universal Mappings --

View File

@ -29,7 +29,7 @@ return {
-- After hours of blood, pain, and tears of trying to tweak dracula colors to
-- be easier on the eyes and have greater contrast, I took one look at the
-- carousel of themes from NvChad and fell in love with tundra...
{ "sam4llis/nvim-tundra",
{ "sam4llis/nvim-tundra", lazy = false, priority = 10000,
config = function () require("plugins/tundra") end,
},
-- Use 'gf' with dot.separated.modules in lua.
@ -102,21 +102,36 @@ return {
fold_closed = "", -- icon used for closed folds
},
},
{ dir = "~/projects/symbols-outline.nvim",
{ 'stevearc/aerial.nvim',
enabled = false,
opts = {
filter_kind = false,
},
-- Optional dependencies
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons"
},
},
{ dir = "~/projects/markdown-toc.nvim", ft = "markdown",
opts = {
-- fences = false,
toc_list = {
-- indent_size = function() return vim.bo.shiftwidth end,
}
},
},
{ dir = "~/projects/outline.nvim",
-- Switched to this from tagbar because it does not require exctags, and it
-- lists the items in order as defined in source code.
-- See github.com/hedyhli/outline.nvim
enabled = vim.fn.has("nvim-0.7") == 1,
cmd = { "SymbolsOutline", "SymbolsOutlineOpen" },
cmd = { "Outline", "OutlineOpen" },
keys = {
{ "<leader>tt", "<cmd>SymbolsOutline<CR>", desc = "Toggle outline window" }
},
opts = {
-- focus_on_open = false,
open_hover_on_preview = false,
keymaps = {
close = "q",
},
{ "<leader>tt", "<cmd>Outline<CR>", desc = "Toggle outline window" },
{ "<leader>tT", "<cmd>OutlineFollow<CR>", desc = "Focus & follow outline window" },
},
config = function() require "plugins/outline" end,
},
-- "bling/vim-bufferline", -- I prefer this over taking over the tabline space thanks
-- Fair well vim-bufferline! You have served my vim and nvim experience well.
@ -140,10 +155,13 @@ return {
commit = 'cde67b5d5427daeecfd7c77cf02ded23a26980bb',
},
{ -- STATUS LINE
-- TODO: Switch to heir for more customizability
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function() require("plugins/statusline") end,
enabled = false,
},
{ "b0o/incline.nvim",
config = function() require("plugins/incline") end,
},
{ "tiagovla/scope.nvim",
-- Tab-local buffer list.
@ -163,11 +181,11 @@ return {
opts = {
highlight = {
multiline = false,
-- The 3 lines below tunes down the coloring of the highlights.
-- The color schemes and treesitter of nowdays are already way too
-- vibrant for my liking, and for someone who litters todo/fixme way
-- too much everywhere, adding *wide* *bg* highlighting to them is just
-- WAY TOO MUCH EYE CANDY AAAA
-- The 3 lines below tunes down the coloring of the highlights. The
-- color schemes and treesitter nowdays are already way too vibrant for
-- my liking, and for someone who litters todo/fixme way too much
-- everywhere, adding *wide* *bg* highlighting to them is just WAY TOO
-- MUCH EYE CANDY AAAA
before = "",
keyword = "fg", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty.
after = "", -- "fg" or "bg" or empty
@ -255,15 +273,19 @@ return {
{ "echasnovski/mini.trailspace",
config = true,
},
{ "lukas-reineke/indent-blankline.nvim",
{ "lukas-reineke/indent-blankline.nvim", name = "ibl",
-- https://github.com/lukas-reineke/indent-blankline.nvim/wiki/Migrate-to-version-3
-- Not documented but it appears new version requires nvim nightly.
-- Upgraded to nvim 0.9.4 and the new version worked with showing context
-- without needing treesitter! 🎉
after = "sam4llis/nvim-tundra",
main = vim.fn.has("nvim-0.9") == 1 and "ibl",
version = vim.fn.has("nvim-0.9") == 0 and "2.20.8",
version = vim.fn.has("nvim-0.9") == 1 and "*" or "2.20.8",
pin = vim.fn.has("nvim-0.9") == 0,
opts = {
-- scope = {
-- highlight = "ErrorMsg",
-- },
exclude = {
filetypes = {
"help",
@ -275,6 +297,7 @@ return {
"notify",
"toggleterm",
"lazyterm",
"Outline"
},
},
},
@ -304,9 +327,6 @@ return {
enabled = false;
},
{ "mzlogin/vim-markdown-toc", ft = "markdown",
config = function ()
vim.opt_local.textwidth = 80
end
},
{ "leafo/moonscript-vim", ft = "moon",
config = function ()
@ -389,10 +409,16 @@ return {
event = "VeryLazy",
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall", "Inspect", "InspectTree" },
config = function() require("plugins/treesitter") end,
dependencies = {
"nvim-treesitter/nvim-treesitter-context",
"nvim-treesitter/nvim-treesitter-textobjects",
},
},
-- Setting these as dependencies of nvim-treesitter causes error of invalid
-- query.
{ "nvim-treesitter/nvim-treesitter-context",
enabled = vim.fn.has('nvim-0.9') == 1,
after = "nvim-treesitter/nvim-treesitter",
},
{ "nvim-treesitter/nvim-treesitter-textobjects",
enabled = vim.fn.has('nvim-0.9') == 1,
after = "nvim-treesitter/nvim-treesitter",
},
{ "windwp/nvim-ts-autotag",
-- Automatically add closing tags for HTML and JSX

View File

@ -166,7 +166,7 @@ require('competitest').setup {
output_compare_method = "squish",
view_output_diff = false,
testcases_directory = ".",
testcases_directory = "./testcases",
testcases_use_single_file = false,
testcases_auto_detect_storage = true,
testcases_single_file_format = "$(FNOEXT)_testcases.txt",

View File

@ -37,7 +37,8 @@ local on_attach = function(client, bufnr)
buf_set_keymap('n', 'gp', '<cmd>lua PeekDefinition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
-- buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
-- Let's not override C-k for window nav thanks
buf_set_keymap('n', '<C-S-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<localleader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<localleader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)

View File

@ -1,3 +1,4 @@
-- NOTE that I no longer use lualine (or any statusline at all)
--- Helpers for status line components ---
-- local function lineinfo()
-- local total = tostring(vim.fn.line('$'))

View File

@ -5,6 +5,7 @@ map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", d"Telescope find_files")
map("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", d"Telescope oldfiles")
map("n", "<leader>fg", "<cmd>Telescope live_grep<cr>", d"Telescope live_grep")
map("n", "<leader>fb", "<cmd>Telescope buffers<cr>", d"Telescope buffers")
map("n", "<leader>bb", "<cmd>Telescope buffers<cr>", d"Telescope buffers")
map("n", "<leader>fh", "<cmd>Telescope help_tags<cr>", d"Telescope help_tags")
map("n", "<leader>fR", "<cmd>Telescope registers<cr>", d"Telescope registers (also see <leader>rg)")

View File

@ -1,4 +1,3 @@
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = {
@ -8,33 +7,33 @@ configs.setup({
highlight = { enable = true },
indent = { enable = true },
-- Textobjects, see below as well
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = { query = "@function.outer", desc = "Around function" },
["if"] = { query = "@function.inner", desc = "Inside function" },
["ac"] = { query = "@class.outer", desc = "Around class" },
["ic"] = { query = "@class.inner", desc = "Inside class" },
-- You can also use captures from other query groups like `locals.scm`
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
},
include_surrounding_whitespace = false,
},
move = {
enable = true,
set_jumps = true,
goto_next = {
["]p"] = "@parameter.outer",
},
goto_previous = {
["[p"] = "@parameter.outer",
},
}
},
-- textobjects = {
-- select = {
-- enable = true,
-- -- Automatically jump forward to textobj, similar to targets.vim
-- lookahead = true,
-- keymaps = {
-- -- You can use the capture groups defined in textobjects.scm
-- ["af"] = { query = "@function.outer", desc = "Around function" },
-- ["if"] = { query = "@function.inner", desc = "Inside function" },
-- ["ac"] = { query = "@class.outer", desc = "Around class" },
-- ["ic"] = { query = "@class.inner", desc = "Inside class" },
-- -- You can also use captures from other query groups like `locals.scm`
-- ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
-- },
-- include_surrounding_whitespace = false,
-- },
-- move = {
-- enable = true,
-- set_jumps = true,
-- goto_next = {
-- ["]p"] = "@parameter.outer",
-- },
-- goto_previous = {
-- ["[p"] = "@parameter.outer",
-- },
-- }
-- },
})
-- TS context

View File

@ -53,8 +53,8 @@ require("nvim-tundra").setup {
fg = s.cp.gray._400,
bg = s.cp.gray._700
},
IblIndent = { fg = s.cp.gray._800 },
IblScope = { fg = s.cp.gray._800 },
IblIndent = { fg = s.cp.gray._1000 },
IblScope = { fg = s.cp.opal._500 },
Comment = { fg = s.cp.gray._400 }, -- Add more contrast
-- Inspired by Modus-Vivendi (emacs).
-- Shows the matched pair more visibly