fix: remove comments and migrate deprecation
This commit is contained in:
34
init.lua
34
init.lua
@@ -41,27 +41,12 @@ require('nvim_comment').setup({
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
require('nvim-ts-autotag').setup()
|
||||
|
||||
-- local function hello()
|
||||
-- local x = vim.fn["nvim_treesitter#statusline(90)"]()
|
||||
-- -- print(x)
|
||||
-- return "test"
|
||||
-- end
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
theme = "everforest",
|
||||
},
|
||||
-- sections = {
|
||||
-- -- lualine_a = { 'mode' },
|
||||
-- -- lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
-- -- lualine_c = { 'filename' },
|
||||
-- lualine_c = { 'filename', hello },
|
||||
-- -- lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
-- -- lualine_y = { 'progress' },
|
||||
-- -- lualine_z = { 'location' }
|
||||
-- },
|
||||
})
|
||||
|
||||
vim.cmd([[colorscheme everforest]])
|
||||
@@ -228,7 +213,6 @@ require "nvim-treesitter.configs".setup({
|
||||
}
|
||||
})
|
||||
|
||||
-- Treesitter Java class + method lookup
|
||||
local ts = vim.treesitter
|
||||
|
||||
local function java_symbol_under_cursor()
|
||||
@@ -247,7 +231,6 @@ local function java_symbol_under_cursor()
|
||||
local class_name = nil
|
||||
local method_name = nil
|
||||
|
||||
-- Walk up the syntax tree
|
||||
while node do
|
||||
local type = node:type()
|
||||
if type == "class_declaration" and not class_name then
|
||||
@@ -306,8 +289,6 @@ local function run_all_tests()
|
||||
end
|
||||
|
||||
|
||||
-- Keymap to print class + method under cursor
|
||||
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
desc = 'Hightlight selection on yank',
|
||||
pattern = '*',
|
||||
@@ -343,31 +324,26 @@ vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
vim.filetype.add({ extension = { templ = "templ" } })
|
||||
|
||||
|
||||
-- Function to find the nearest directory containing go.mod
|
||||
local function find_go_mod_root()
|
||||
local path = vim.fn.expand("%:p:h") -- current file's directory
|
||||
local root = vim.fn.finddir("go.mod", path .. ";") -- search upwards
|
||||
local path = vim.fn.expand("%:p:h")
|
||||
local root = vim.fn.finddir("go.mod", path .. ";")
|
||||
if root == "" then
|
||||
return nil -- fallback if no go.mod found
|
||||
return nil
|
||||
else
|
||||
return vim.fn.fnamemodify(root, ":h") -- directory containing go.mod
|
||||
return vim.fn.fnamemodify(root, ":h")
|
||||
end
|
||||
end
|
||||
|
||||
-- Autocmd for Go files
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "go",
|
||||
callback = function()
|
||||
-- Set makeprg to run in the module root
|
||||
local root = find_go_mod_root()
|
||||
if root then
|
||||
-- cd into the module root, then run go
|
||||
vim.opt_local.makeprg = "cd " .. root .. " && go build ./..."
|
||||
else
|
||||
vim.opt_local.makeprg = "go build ./..."
|
||||
end
|
||||
|
||||
-- Set errorformat for Go errors
|
||||
vim.opt_local.errorformat = table.concat({
|
||||
"%f:%l:%c: %m",
|
||||
"%f:%l: %m",
|
||||
@@ -393,7 +369,7 @@ vim.keymap.set('n', '<F4>', vim.lsp.buf.code_action, {})
|
||||
vim.keymap.set('n', '<leader>q', ':q<CR>', { desc = "Quit current Buffer" })
|
||||
vim.keymap.set('n', '<leader>w', ':w<CR>', { desc = "Write current Buffer" })
|
||||
vim.keymap.set('n', '<Esc>', ':noh<CR><C-l>', { desc = "Clear search and redraw" })
|
||||
vim.keymap.set('n', '<F2>', vim.diagnostic.goto_next, {})
|
||||
vim.keymap.set('n', '<F2>', function() vim.diagnostic.jump({ count = 1 }) end, {})
|
||||
|
||||
vim.keymap.set("n", "<C-h>", "<C-w>h")
|
||||
-- Terminal is sending Backspace instead of <C-h>, so this needs to be different
|
||||
|
||||
Reference in New Issue
Block a user