lag-fix #9
6 changed files with 91 additions and 92 deletions
9
lsp/lsp_ls.lua
Normal file
9
lsp/lsp_ls.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -1,23 +1,19 @@
|
||||||
return {
|
return {
|
||||||
{
|
|
||||||
'windwp/nvim-autopairs',
|
'windwp/nvim-autopairs',
|
||||||
event = "InsertEnter",
|
event = 'InsertEnter',
|
||||||
config = function()
|
opts = {
|
||||||
local autopairs = require("nvim-autopairs")
|
fast_wrap = {},
|
||||||
autopairs.setup({
|
|
||||||
check_ts = false,
|
|
||||||
map_cr = false,
|
map_cr = false,
|
||||||
ts_config = {
|
|
||||||
lua = { "string" },
|
|
||||||
dart = { "string_literal" }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
|
||||||
local pcall_cmp, cmp = pcall(require, "cmp")
|
|
||||||
if pcall_cmp then
|
|
||||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
-- Initialize autopairs with your choices
|
||||||
|
require('nvim-autopairs').setup(opts)
|
||||||
|
|
||||||
|
-- Safely hook into cmp if it's already available
|
||||||
|
local cmp_status, cmp = pcall(require, 'cmp')
|
||||||
|
if cmp_status then
|
||||||
|
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||||
|
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||||
|
end
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
return {
|
return {
|
||||||
"github/copilot.vim",
|
"github/copilot.vim",
|
||||||
lazy = false,
|
-- lazy = false,
|
||||||
|
cmd = "Copilot",
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<C-l",
|
||||||
|
'copilot#Accept("\\<CR>")',
|
||||||
|
mode = "i",
|
||||||
|
expr = true,
|
||||||
|
replace_keycodes = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
config = function()
|
config = function()
|
||||||
vim.g.copilot_enabled = false
|
vim.g.copilot_enabled = false
|
||||||
vim.g.copilot_no_tab_map = true
|
|
||||||
vim.keymap.set('i', '<C-l>', 'copilot#Accept("\\<CR>")', {
|
|
||||||
expr = true,
|
|
||||||
replace_keycodes = false
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,34 +8,13 @@ return {
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
-- vim.env.FLUTTER_FORCE_COLOR = "1"
|
|
||||||
local project_root = vim.fn.getcwd()
|
|
||||||
local analysis_excluded_folders = {
|
|
||||||
project_root .. "/.dart_tool",
|
|
||||||
project_root .. "/build",
|
|
||||||
project_root .. "/ios/Pods",
|
|
||||||
project_root .. "/android/.gradle",
|
|
||||||
}
|
|
||||||
local flutter_bin = vim.fn.exepath("flutter")
|
|
||||||
if flutter_bin ~= "" then
|
|
||||||
local flutter_sdk = vim.fn.fnamemodify(vim.fn.resolve(flutter_bin), ":h:h")
|
|
||||||
table.insert(analysis_excluded_folders, flutter_sdk .. "/packages")
|
|
||||||
table.insert(analysis_excluded_folders, flutter_sdk .. "/.pub-cache")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Auto scroll & Color logs when new logs appear
|
|
||||||
vim.api.nvim_create_autocmd({ "TextChanged", "BufWinEnter" }, {
|
vim.api.nvim_create_autocmd({ "TextChanged", "BufWinEnter" }, {
|
||||||
pattern = "*__FLUTTER_DEV_LOG__*",
|
pattern = "*__FLUTTER_DEV_LOG__*",
|
||||||
callback = function()
|
callback = function()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
-- Auto-scroll logic
|
|
||||||
if vim.bo[buf].filetype == "log" or vim.fn.bufname(buf):match("flutter%-dev%.log") then
|
if vim.bo[buf].filetype == "log" or vim.fn.bufname(buf):match("flutter%-dev%.log") then
|
||||||
local win = vim.api.nvim_get_current_win()
|
vim.cmd("normal! G")
|
||||||
local last_line = vim.api.nvim_buf_line_count(buf)
|
|
||||||
if vim.api.nvim_get_mode().mode ~= 'i' then
|
|
||||||
vim.api.nvim_win_set_cursor(win, { last_line, 0 })
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
@ -55,16 +34,22 @@ return {
|
||||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
client.server_capabilities.semanticTokensProvider = nil
|
client.server_capabilities.semanticTokensProvider = nil
|
||||||
|
client.server_capabilities.documentOnTypeFormattingProvider = nil
|
||||||
|
-- client.server_capabilities.diagnosticProvider = nil
|
||||||
end,
|
end,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150, -- milliseconds
|
||||||
|
},
|
||||||
settings = {
|
settings = {
|
||||||
showTodos = true,
|
showTodos = true,
|
||||||
completeFunctionCalls = false,
|
completeFunctionCalls = false,
|
||||||
|
renameFilesWithClasses = "prompt",
|
||||||
|
enableSnippets = true,
|
||||||
updateImportsOnRename = true,
|
updateImportsOnRename = true,
|
||||||
analysisExcludedFolders = analysis_excluded_folders,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
widget_guides = {
|
widget_guides = {
|
||||||
enabled = false,
|
enabled = true,
|
||||||
},
|
},
|
||||||
closing_tags = {
|
closing_tags = {
|
||||||
enabled = false,
|
enabled = false,
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,26 @@ return {
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
local mason_lspconfig = require("mason-lspconfig")
|
local mason_lspconfig = require("mason-lspconfig")
|
||||||
|
|
||||||
-- Register global capabilities for all servers
|
-- 1. Global capabilities registered natively for all servers
|
||||||
vim.lsp.config("*", {
|
vim.lsp.config("*", {
|
||||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.lsp.config("lua_ls", {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = vim.env.VIMRUNTIME,
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
"lua_ls",
|
"lua_ls",
|
||||||
"pyright",
|
"pyright",
|
||||||
|
|
@ -33,51 +48,43 @@ return {
|
||||||
ensure_installed = servers,
|
ensure_installed = servers,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Neovim 0.11+ approach: Configure and Enable
|
|
||||||
for _, server_name in ipairs(servers) do
|
for _, server_name in ipairs(servers) do
|
||||||
if server_name == "lua_ls" then
|
|
||||||
vim.lsp.config("lua_ls", {
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
diagnostics = { globals = { "vim" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
-- Activate the server
|
|
||||||
if server_name ~= "dartls" then
|
if server_name ~= "dartls" then
|
||||||
vim.lsp.enable(server_name)
|
vim.lsp.enable(server_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Diagnostic display config
|
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = true,
|
virtual_text = true,
|
||||||
signs = true,
|
signs = true,
|
||||||
underline = true,
|
underline = true,
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
float = { border = "rounded", source = true },
|
severity_sort = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Keybindings & Formatting
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
local opts = { buffer = ev.buf }
|
local opts = { buffer = ev.buf }
|
||||||
-- Neovim 0.11+ provides some defaults like 'grn' (rename),
|
|
||||||
-- but keeping your custom ones is fine.
|
|
||||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.hover, opts)
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.hover, opts)
|
||||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||||
vim.keymap.set({ "n", "v" }, "<C-.>", vim.lsp.buf.code_action, opts)
|
vim.keymap.set({ "n", "v" }, "<C-.>", vim.lsp.buf.code_action, opts)
|
||||||
-- Diagnostic keymaps
|
|
||||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts) -- show error under cursor
|
-- Diagnostics
|
||||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous error
|
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next error
|
vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = -1, float = true }) end, opts)
|
||||||
vim.keymap.set("n", "<leader>el", vim.diagnostic.setloclist, opts) -- all errors in quickfix list
|
vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = 1, float = true }) end, opts)
|
||||||
vim.keymap.set("n", "<leader>af", vim.lsp.buf.format, { desc = "Format file" }) -- manual format
|
vim.keymap.set("n", "<leader>el", vim.diagnostic.setloclist, opts)
|
||||||
-- Format on save (with filter to prevent multi-client conflicts)
|
|
||||||
|
-- Explicit formatting configuration
|
||||||
|
vim.keymap.set("n", "<leader>af", function()
|
||||||
|
vim.lsp.buf.format({ async = true })
|
||||||
|
end, { buffer = ev.buf, desc = "Format file" })
|
||||||
|
|
||||||
|
-- Safe Format on Save scoped specifically to current buffer
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
buffer = ev.buf,
|
buffer = ev.buf,
|
||||||
callback = function()
|
callback = function()
|
||||||
|
|
@ -130,13 +137,12 @@ return {
|
||||||
{
|
{
|
||||||
name = "buffer",
|
name = "buffer",
|
||||||
keyword_length = 2,
|
keyword_length = 2,
|
||||||
-- Limit indexing to only the active visible buffer to stop lag on Enter
|
|
||||||
option = {
|
option = {
|
||||||
get_bufnrs = function()
|
get_bufnrs = function()
|
||||||
return { vim.api.nvim_get_current_buf() }
|
return { vim.api.nvim_get_current_buf() }
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}, -- Triggers after typing 2 characters of a local word
|
},
|
||||||
{ name = "path" },
|
{ name = "path" },
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
return {
|
return {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
lazy = false, -- Treesitter must not be lazy-loaded in the new version
|
lazy = false,
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
local ts = require("nvim-treesitter")
|
local ts = require("nvim-treesitter")
|
||||||
|
|
@ -9,28 +9,26 @@ return {
|
||||||
"dockerfile", "yaml", "bash", "json", "html",
|
"dockerfile", "yaml", "bash", "json", "html",
|
||||||
"css", "javascript", "sql", "markdown", "markdown_inline",
|
"css", "javascript", "sql", "markdown", "markdown_inline",
|
||||||
}
|
}
|
||||||
-- 1. Global Settings
|
|
||||||
ts.setup({
|
ts.setup({
|
||||||
install_dir = vim.fn.stdpath("data") .. "/site",
|
install_dir = vim.fn.stdpath("data") .. "/site",
|
||||||
auto_install = true,
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
indent = {
|
|
||||||
enable = true,
|
|
||||||
disable = { "dart" },
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
-- 2. Bulk Install Parsers (Asynchronous)
|
local already_installed = require("nvim-treesitter.config").get_installed()
|
||||||
ts.install(supported_languages)
|
local parsers_to_install = {}
|
||||||
-- 3. Enable Highlighting
|
|
||||||
|
for _, lang in ipairs(supported_languages) do
|
||||||
|
if not vim.tbl_contains(already_installed, lang) then
|
||||||
|
table.insert(parsers_to_install, lang)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #parsers_to_install > 0 then
|
||||||
|
ts.install(parsers_to_install)
|
||||||
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = supported_languages,
|
pattern = supported_languages,
|
||||||
callback = function()
|
callback = function()
|
||||||
local lang = vim.treesitter.language.get_lang(vim.bo.filetype)
|
|
||||||
if lang then
|
|
||||||
vim.treesitter.start()
|
vim.treesitter.start()
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue