adjust lsp
This commit is contained in:
@@ -1,103 +0,0 @@
|
||||
-- alternatively you can override the default configs
|
||||
require("flutter-tools").setup {
|
||||
ui = {
|
||||
-- the border type to use for all floating windows, the same options/formats
|
||||
-- used for ":h nvim_open_win" e.g. "single" | "shadow" | {<table-of-eight-chars>}
|
||||
border = "rounded",
|
||||
-- This determines whether notifications are show with `vim.notify` or with the plugin's custom UI
|
||||
-- please note that this option is eventually going to be deprecated and users will need to
|
||||
-- depend on plugins like `nvim-notify` instead.
|
||||
notification_style = 'native' -- | 'plugin'
|
||||
},
|
||||
decorations = {
|
||||
statusline = {
|
||||
-- set to true to be able use the 'flutter_tools_decorations.app_version' in your statusline
|
||||
-- this will show the current version of the flutter app from the pubspec.yaml file
|
||||
app_version = false,
|
||||
-- set to true to be able use the 'flutter_tools_decorations.device' in your statusline
|
||||
-- this will show the currently running device if an application was started with a specific
|
||||
-- device
|
||||
device = false,
|
||||
-- set to true to be able use the 'flutter_tools_decorations.project_config' in your statusline
|
||||
-- this will show the currently selected project configuration
|
||||
project_config = false,
|
||||
}
|
||||
},
|
||||
debugger = { -- integrate with nvim dap + install dart code debugger
|
||||
enabled = false,
|
||||
-- if empty dap will not stop on any exceptions, otherwise it will stop on those specified
|
||||
-- see |:help dap.set_exception_breakpoints()| for more info
|
||||
exception_breakpoints = {},
|
||||
-- Whether to call toString() on objects in debug views like hovers and the
|
||||
-- variables list.
|
||||
-- Invoking toString() has a performance cost and may introduce side-effects,
|
||||
-- although users may expected this functionality. null is treated like false.
|
||||
evaluate_to_string_in_debug_views = true,
|
||||
-- You can use the `debugger.register_configurations` to register custom runner configuration (for example for different targets or flavor). Plugin automatically registers the default configuration, but you can override it or add new ones.
|
||||
-- register_configurations = function(paths)
|
||||
-- require("dap").configurations.dart = {
|
||||
-- -- your custom configuration
|
||||
-- }
|
||||
-- end,
|
||||
},
|
||||
-- flutter_path = "/opt/flutter", -- <-- this takes priority over the lookup
|
||||
-- flutter_lookup_cmd = nil, -- example "dirname $(which flutter)" or "asdf where flutter"
|
||||
root_patterns = { ".git", "pubspec.yaml" }, -- patterns to find the root of your flutter project
|
||||
fvm = false, -- takes priority over path, uses <workspace>/.fvm/flutter_sdk if enabled
|
||||
default_run_args= nil, -- Default options for run command (i.e `{ flutter = "--no-version-check" }`). Configured separately for `dart run` and `flutter run`.
|
||||
widget_guides = {
|
||||
enabled = false,
|
||||
},
|
||||
closing_tags = {
|
||||
highlight = "ErrorMsg", -- highlight for the closing tag
|
||||
prefix = ">", -- character to use for close tag e.g. > Widget
|
||||
priority = 10, -- priority of virtual text in current line
|
||||
-- consider to configure this when there is a possibility of multiple virtual text items in one line
|
||||
-- see `priority` option in |:help nvim_buf_set_extmark| for more info
|
||||
enabled = true -- set to false to disable
|
||||
},
|
||||
dev_log = {
|
||||
enabled = true,
|
||||
filter = nil, -- optional callback to filter the log
|
||||
-- takes a log_line as string argument; returns a boolean or nil;
|
||||
-- the log_line is only added to the output if the function returns true
|
||||
notify_errors = false, -- if there is an error whilst running then notify the user
|
||||
open_cmd = "15split", -- command to use to open the log buffer
|
||||
focus_on_open = true, -- focus on the newly opened log window
|
||||
},
|
||||
dev_tools = {
|
||||
autostart = false, -- autostart devtools server if not detected
|
||||
auto_open_browser = false, -- Automatically opens devtools in the browser
|
||||
},
|
||||
outline = {
|
||||
open_cmd = "30vnew", -- command to use to open the outline buffer
|
||||
auto_open = false -- if true this will open the outline automatically when it is first populated
|
||||
},
|
||||
lsp = {
|
||||
color = { -- show the derived colours for dart variables
|
||||
enabled = false, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
|
||||
background = false, -- highlight the background
|
||||
background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
|
||||
foreground = false, -- highlight the foreground
|
||||
virtual_text = true, -- show the highlight using virtual text
|
||||
virtual_text_str = "■", -- the virtual text character to highlight
|
||||
},
|
||||
on_attach = my_custom_on_attach,
|
||||
capabilities = my_custom_capabilities, -- e.g. lsp_status capabilities
|
||||
--- OR you can specify a function to deactivate or change or control how the config is created
|
||||
capabilities = function(config)
|
||||
config.specificThingIDontWant = false
|
||||
return config
|
||||
end,
|
||||
-- see the link below for details on each option:
|
||||
-- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration
|
||||
-- settings = {
|
||||
-- showTodos = true,
|
||||
-- completeFunctionCalls = true,
|
||||
-- analysisExcludedFolders = {"<path-to-flutter-sdk-packages>"},
|
||||
-- renameFilesWithClasses = "prompt", -- "always"
|
||||
-- enableSnippets = true,
|
||||
-- updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command.
|
||||
-- }
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
-- local llm = require('llm')
|
||||
--
|
||||
-- llm.setup({
|
||||
-- api_token = nil, -- cf Install paragraph
|
||||
-- model = "codellama:7b-code", -- the model ID, behavior depends on backend
|
||||
-- backend = "ollama", -- backend ID, "huggingface" | "ollama" | "openai" | "tgi"
|
||||
-- url = "", -- the http url of the backend
|
||||
--
|
||||
-- tokens_to_clear = { "<EOT>" }, -- tokens to remove from the model's output
|
||||
-- -- parameters that are added to the request body, values are arbitrary, you can set any field:value pair here it will be passed as is to the backend
|
||||
-- request_body = {
|
||||
-- parameters = {
|
||||
-- max_new_tokens = 120,
|
||||
-- temperature = 0.2,
|
||||
-- top_p = 0.95,
|
||||
-- rope_frequency_base = 1000000
|
||||
-- },
|
||||
-- },
|
||||
-- -- set this if the model supports fill in the middle
|
||||
-- fim = {
|
||||
-- enabled = true,
|
||||
-- prefix = "<PRE> ",
|
||||
-- middle = " <MID>",
|
||||
-- suffix = " <SUF>",
|
||||
--
|
||||
-- },
|
||||
-- debounce_ms = 500,
|
||||
-- accept_keymap = "<A-a>",
|
||||
-- dismiss_keymap = "<A-d>",
|
||||
-- tls_skip_verify_insecure = false,
|
||||
-- -- llm-ls configuration, cf llm-ls section
|
||||
-- lsp = {
|
||||
-- bin_path = nil,
|
||||
-- host = nil,
|
||||
-- port = nil,
|
||||
-- cmd_env = nil, -- or { LLM_LOG_LEVEL = "DEBUG" } to set the log level of llm-ls
|
||||
-- version = "0.5.3",
|
||||
-- },
|
||||
-- tokenizer = nil, -- cf Tokenizer paragraph
|
||||
-- context_window = 4048, -- max number of tokens for the context window
|
||||
-- enable_suggestions_on_startup = true,
|
||||
-- enable_suggestions_on_files = "*", -- pattern matching syntax to enable suggestions on specific files, either a string or a list of strings
|
||||
-- disable_url_path_completion = false, -- cf Backend
|
||||
-- })
|
||||
+67
-65
@@ -1,24 +1,44 @@
|
||||
local lsp = require("lsp-zero")
|
||||
|
||||
lsp.preset("recommended")
|
||||
|
||||
require("mason").setup({})
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"ts_ls",
|
||||
"eslint",
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"ast_grep"
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require("lspconfig")[server_name].setup({})
|
||||
end,
|
||||
}
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local servers = {
|
||||
ts_ls = {},
|
||||
eslint = {},
|
||||
lua_ls = {
|
||||
cmd = { "lua-language-server" },
|
||||
filetypes = { "lua" }
|
||||
},
|
||||
rust_analyzer = {},
|
||||
ast_grep = {},
|
||||
}
|
||||
|
||||
---@type lsp.ClientCapabilities
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
for server, config in pairs(servers) do
|
||||
servers[server].capabilities = capabilities
|
||||
vim.lsp.config(server, config)
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local opts = { buffer = args.buf }
|
||||
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
|
||||
-- vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = 1, float = true }) end, opts)
|
||||
-- vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = -1, float = true }) end, opts)
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
|
||||
end
|
||||
})
|
||||
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
window = {
|
||||
@@ -26,53 +46,35 @@ cmp.setup({
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-j>'] = cmp.mapping.select_next_item(),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<CR>"] = cmp.mapping.confirm(),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
}
|
||||
})
|
||||
|
||||
lsp.extend_lspconfig()
|
||||
require("mason").setup()
|
||||
|
||||
lsp.set_preferences({
|
||||
sign_icons = {}
|
||||
})
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set("n", "gd", builtin.lsp_definitions, {})
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
lsp.default_keymaps({ buffer = bufnr })
|
||||
|
||||
local opts = { buffer = bufnr, remap = false }
|
||||
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>gd", builtin.lsp_definitions, {})
|
||||
vim.keymap.set('n', '<leader>cf', builtin.lsp_incoming_calls)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end)
|
||||
|
||||
lsp.setup()
|
||||
|
||||
-- Function to restart all active LSP clients
|
||||
local function restart_lsp()
|
||||
for _, client in pairs(vim.lsp.get_active_clients()) do
|
||||
client.stop()
|
||||
end
|
||||
vim.cmd("edit") -- Reload the current buffer to reattach the LSP clients
|
||||
end
|
||||
|
||||
-- Create a Neovim command to restart LSP
|
||||
vim.api.nvim_create_user_command('LspRestart', restart_lsp, {})
|
||||
local ensure_installed = {
|
||||
"ast-grep",
|
||||
"clangd",
|
||||
"diagnostic-languageserver",
|
||||
"eslint-lsp",
|
||||
"jdtls",
|
||||
"json-lsp",
|
||||
"lua-language-server",
|
||||
"python-lsp-server",
|
||||
"some-sass-language-server",
|
||||
"tombi",
|
||||
"rust-analyzer",
|
||||
"typescript-language-server",
|
||||
"yaml-language-server",
|
||||
"jinja-lsp"
|
||||
}
|
||||
vim.api.nvim_create_user_command("MasonInstallAll", function()
|
||||
local packages = table.concat(ensure_installed, " ")
|
||||
vim.cmd("MasonInstall " .. packages)
|
||||
end, {})
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
-- require("mini.align").setup()
|
||||
@@ -1,43 +0,0 @@
|
||||
-- local g = vim.g
|
||||
--
|
||||
-- local options_append = {
|
||||
-- netrw_keepdir = 0, --Keep the current directory and the browsing directory synced
|
||||
-- netrw_winsize = "17", -- 17% size
|
||||
-- netrw_localmkdir = "mkdir -p", -- change mkdir cmd
|
||||
-- netrw_localcopycmd = "cp -r", -- change copy command
|
||||
-- netrw_localrmdir = "rm -r", -- change delete command
|
||||
-- netrw_list_hide = [['\(^\|\s\s\)\zs\.\S\+']], -- don't show hidden
|
||||
-- --netrw_banner = 0, -- hide banner
|
||||
-- --netrw_liststyle = 3, -- how files are open
|
||||
-- --netrw_browse_split = 0, -- open new files in vertical split
|
||||
-- -- netrw_altv = 1,
|
||||
-- netrw_bufsettings = "noma nomod nu nobl nowrap ro", -- line number
|
||||
-- }
|
||||
--
|
||||
-- for k, v in pairs(options_append) do
|
||||
-- g[k] = v
|
||||
-- end
|
||||
--
|
||||
-- local bind = function(lhs, rhs)
|
||||
-- vim.keymap.set("n", lhs, rhs, { remap = true, buffer = true })
|
||||
-- end
|
||||
--
|
||||
-- -- Navigation
|
||||
-- bind("l", "<CR>") -- open file or dir
|
||||
-- bind(".", "gh") -- toggle dotfiles
|
||||
-- bind("H", "u") -- preview dir
|
||||
-- bind("h", "-^") -- go up
|
||||
-- bind("[f", ":Explore<CR>") -- close if open
|
||||
--
|
||||
-- -- Marks
|
||||
-- bind("<TAB>", "mf") -- toggle mark
|
||||
-- bind("<S-TAB>", "mF") -- unmark
|
||||
-- bind("<leader><TAB>", "mu") -- unmark all
|
||||
--
|
||||
-- -- Files
|
||||
-- bind("ff", ":!touch ") -- create file
|
||||
-- bind("fd", ":!mkdir -p ") -- create folder
|
||||
-- bind("fm", ":!mv ") -- move/rename
|
||||
-- bind("fc", ":!cp -r ") -- copy
|
||||
-- bind("D", ":!rm -r ") -- delete
|
||||
-- bind("f;", "mx") -- run command
|
||||
Reference in New Issue
Block a user