我按照以下说明进行操作:
https://github.com/nvim-lua/kickstart.nvim https://youtu.be/m8C0Cq9Uv9o?feature=shared
我正在使用带有 gcc 的 Windows。我使用 Microsoft 终端 (cmd)(可在 Microsoft Store 上找到)作为我的终端。 除了 clangd LSP 之外,几乎一切都运行良好。 只是取消注释
clangd={}
并在下次启动时通过 mason 安装它,不会告诉 clangd 库文件在哪里,并且它无法识别 <iostrem>
或 <bits\stdc++.h>
。
我无法弄清楚在 Windows 中的这些约束中设置此设置的正确方法是什么。
如果有人之前在 Windows 中使用lazy.nvim 和 lua 进行过设置,那么任何帮助都会很棒。我可以使用 WSL,但我想将其保留在本机窗口中,以便无缝地编辑 Windows 文件。
这里是来自kickstart.nvim项目的
init.lua
中的相关代码:
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
-- Add any additional override configuration in the following tables. Available keys are:
-- - cmd (table): Override the default command used to start the server
-- - filetypes (table): Override the default list of associated filetypes for the server
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
clangd = {},
-- gopls = {},
pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
--
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}
-- Ensure the servers and tools above are installed
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- :Mason
--
-- You can press `g?` for help in this menu.
require('mason').setup()
-- You can add other tools here that you want Mason to install
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
}
end,
},
我尝试使用
添加所需库文件的路径set CPLUS_INCLUDE_PATH=C:\ProgramData\mingw64\mingw64\lib\gcc\x86_64-w64-mingw32\13.2.0;C:\ProgramData\mingw64\mingw64\lib\gcc\x86_64-w64-mingw32\13.2.0\include;C:\ProgramData\mingw64\mingw64\lib\gcc\x86_64-w64-mingw32\13.2.0\include\c++;C:\ProgramData\mingw64\mingw64\lib\gcc\x86_64-w64-mingw32\13.2.0\include\c++\x86_64-w64-mingw32
但是我收到了各种错误,例如:错误图像
我可以通过在 clangd config.yaml 文件的编译标志中添加 mingw 编译器作为编译器来解决这个问题。