apply josean patches 2
This commit is contained in:
@@ -23,7 +23,7 @@ return {
|
||||
dashboard.button("SPC ee", " > Toggle file explorer", "<cmd>NvimTreeToggle<CR>"),
|
||||
dashboard.button("SPC ff", " > Find File", "<cmd>Telescope find_files<CR>"),
|
||||
dashboard.button("SPC fs", " > Find Word", "<cmd>Telescope live_grep<CR>"),
|
||||
dashboard.button("SPC wr", " > Restore Session For Current Directory", "<cmd>SessionRestore<CR>"),
|
||||
dashboard.button("SPC wr", " > Restore Session For Current Directory", "<cmd>AutoSession restore<CR>"),
|
||||
dashboard.button("q", " > Quit NVIM", "<cmd>qa<CR>"),
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ return {
|
||||
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "<leader>wr", "<cmd>SessionRestore<CR>", { desc = "Restore session for cwd" }) -- restore last workspace session for current directory
|
||||
keymap.set("n", "<leader>ws", "<cmd>SessionSave<CR>", { desc = "Save session for auto session root dir" }) -- save workspace session for current working directory
|
||||
keymap.set("n", "<leader>wr", "<cmd>AutoSession restore<CR>", { desc = "Restore session for cwd" }) -- restore last workspace session for current directory
|
||||
keymap.set("n", "<leader>ws", "<cmd>AutoSession save<CR>", { desc = "Save session for auto session root dir" }) -- save workspace session for current working directory
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ return {
|
||||
format_on_save = {
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
timeout_ms = 1000,
|
||||
timeout_ms = 3000,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -5,25 +5,64 @@ return {
|
||||
local lint = require("lint")
|
||||
|
||||
lint.linters_by_ft = {
|
||||
javascript = { "eslint_d" },
|
||||
typescript = { "eslint_d" },
|
||||
javascriptreact = { "eslint_d" },
|
||||
typescriptreact = { "eslint_d" },
|
||||
svelte = { "eslint_d" },
|
||||
python = { "pylint" },
|
||||
}
|
||||
|
||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||
|
||||
local function file_in_cwd(file_name)
|
||||
return vim.fs.find(file_name, {
|
||||
upward = true,
|
||||
stop = vim.loop.cwd():match("(.+)/"),
|
||||
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
|
||||
type = "file",
|
||||
})[1]
|
||||
end
|
||||
|
||||
local function remove_linter(linters, linter_name)
|
||||
for k, v in pairs(linters) do
|
||||
if v == linter_name then
|
||||
linters[k] = nil
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function linter_in_linters(linters, linter_name)
|
||||
for k, v in pairs(linters) do
|
||||
if v == linter_name then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function remove_linter_if_missing_config_file(linters, linter_name, config_file_name)
|
||||
if linter_in_linters(linters, linter_name) and not file_in_cwd(config_file_name) then
|
||||
remove_linter(linters, linter_name)
|
||||
end
|
||||
end
|
||||
|
||||
local function try_linting()
|
||||
local linters = lint.linters_by_ft[vim.bo.filetype]
|
||||
|
||||
-- if linters then
|
||||
-- -- remove_linter_if_missing_config_file(linters, "eslint_d", ".eslintrc.cjs")
|
||||
-- remove_linter_if_missing_config_file(linters, "eslint_d", "eslint.config.js")
|
||||
-- end
|
||||
|
||||
lint.try_lint(linters)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
group = lint_augroup,
|
||||
callback = function()
|
||||
lint.try_lint()
|
||||
try_linting()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>l", function()
|
||||
lint.try_lint()
|
||||
try_linting()
|
||||
end, { desc = "Trigger linting for current file" })
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -1,101 +1,19 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
-- Falls nicht bereits woanders eingebunden:
|
||||
-- { "mason-org/mason-lspconfig.nvim", opts = {} },
|
||||
{ "folke/lazydev.nvim", opts = {} },
|
||||
},
|
||||
config = function()
|
||||
-- cmp capabilities global setzen (für alle Server)
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
-- import cmp-nvim-lsp plugin
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
|
||||
-- used to enable autocompletion (assign to every lsp server config)
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
vim.lsp.config("*", {
|
||||
capabilities = capabilities,
|
||||
}) -- :help lsp-config-merge
|
||||
|
||||
-- Keymaps bei Attach (deins, unveraendert)
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
local keymap = vim.keymap
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts)
|
||||
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts)
|
||||
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts)
|
||||
|
||||
opts.desc = "Show line diagnostics"
|
||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
|
||||
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", function()
|
||||
vim.diagnostic.jump({ count = -1, float = true })
|
||||
end, opts)
|
||||
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", function()
|
||||
vim.diagnostic.jump({ count = 1, float = true })
|
||||
end, opts)
|
||||
|
||||
opts.desc = "Show documentation"
|
||||
keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Diagnostics-UI
|
||||
local x = vim.diagnostic.severity
|
||||
vim.diagnostic.config({
|
||||
virtual_text = { prefix = "" },
|
||||
signs = { text = { [x.ERROR] = "", [x.WARN] = "", [x.INFO] = "", [x.HINT] = "" } },
|
||||
underline = true,
|
||||
float = { border = "single" },
|
||||
})
|
||||
|
||||
-- Server-spezifisch: Lua
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
completion = { callSnippet = "Replace" },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- (Optional) Mason-LSPConfig: Installer + kein Auto-Enable (wir enablen selbst)
|
||||
local ok_mason, mason_lspconfig = pcall(require, "mason-lspconfig")
|
||||
if ok_mason then
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = { "html", "cssls", "tailwindcss", "lua_ls", "pyright" },
|
||||
automatic_enable = false, -- sonst wuerde Mason selbst enable() rufen
|
||||
})
|
||||
end
|
||||
|
||||
-- Neovim 0.11+: Server aktivieren (statt lspconfig[server].setup)
|
||||
vim.lsp.enable({ "html", "cssls", "tailwindcss", "lua_ls", "pyright" })
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
return {
|
||||
"williamboman/mason.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
opts = {
|
||||
-- list of servers for mason to install
|
||||
ensure_installed = {
|
||||
"ts_ls",
|
||||
"html",
|
||||
"cssls",
|
||||
"tailwindcss",
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"eslint",
|
||||
},
|
||||
config = function()
|
||||
-- import mason
|
||||
local mason = require("mason")
|
||||
|
||||
-- import mason-lspconfig
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
local mason_tool_installer = require("mason-tool-installer")
|
||||
|
||||
-- enable mason and configure icons
|
||||
mason.setup({
|
||||
},
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
@@ -22,29 +24,25 @@ return {
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
mason_lspconfig.setup({
|
||||
-- list of servers for mason to install
|
||||
ensure_installed = {
|
||||
"html",
|
||||
"cssls",
|
||||
"tailwindcss",
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
},
|
||||
automatic_enable = false,
|
||||
})
|
||||
|
||||
mason_tool_installer.setup({
|
||||
},
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
},
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"prettier", -- prettier formatter
|
||||
"stylua", -- lua formatter
|
||||
"isort", -- python formatter
|
||||
"black", -- python formatter
|
||||
"pylint", -- python linter
|
||||
"eslint_d", -- js linter
|
||||
"pylint",
|
||||
"eslint_d",
|
||||
},
|
||||
},
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ return {
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
completion = {
|
||||
completeopt = "menu,menuone,preview,noselect",
|
||||
},
|
||||
snippet = { -- configure how nvim-cmp interacts with snippet engine
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
|
||||
@@ -10,7 +10,7 @@ return {
|
||||
|
||||
nvimtree.setup({
|
||||
view = {
|
||||
width = 35,
|
||||
width = 50,
|
||||
relativenumber = true,
|
||||
},
|
||||
-- change folder arrow icons
|
||||
@@ -49,8 +49,13 @@ return {
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
|
||||
keymap.set("n", "<leader>ee", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle file explorer" }) -- toggle file explorer
|
||||
keymap.set("n", "<leader>ef", "<cmd>NvimTreeFindFileToggle<CR>", { desc = "Toggle file explorer on current file" }) -- toggle file explorer on current file
|
||||
keymap.set(
|
||||
"n",
|
||||
"<leader>ef",
|
||||
"<cmd>NvimTreeFindFileToggle<CR>",
|
||||
{ desc = "Toggle file explorer on current file" }
|
||||
) -- toggle file explorer on current file
|
||||
keymap.set("n", "<leader>ec", "<cmd>NvimTreeCollapse<CR>", { desc = "Collapse file explorer" }) -- collapse file explorer
|
||||
keymap.set("n", "<leader>er", "<cmd>NvimTreeRefresh<CR>", { desc = "Refresh file explorer" }) -- refresh file explorer
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
build = ":TSUpdate",
|
||||
dependencies = {
|
||||
"windwp/nvim-ts-autotag",
|
||||
},
|
||||
config = function()
|
||||
-- import nvim-treesitter plugin
|
||||
local treesitter = require("nvim-treesitter.configs")
|
||||
@@ -14,17 +11,8 @@ return {
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
sync_install = false,
|
||||
ignore_install = {},
|
||||
auto_install = false,
|
||||
|
||||
-- enable indentation
|
||||
indent = { enable = true },
|
||||
-- enable autotagging (w/ nvim-ts-autotag plugin)
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
-- ensure these language parsers are installed
|
||||
ensure_installed = {
|
||||
"json",
|
||||
@@ -58,5 +46,8 @@ return {
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- use bash parser for zsh files
|
||||
vim.treesitter.language.register("bash", "zsh")
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user