initial commit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
-- KEYBINDS
|
||||
vim.g.mapleader = " "
|
||||
vim.keymap.set("n", "<leader>cd", vim.cmd.Ex)
|
||||
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- Alt Up/Down in vscode
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
vim.keymap.set("n", "J", "mzJ`z") -- Remap joining lines
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz") -- Keep cursor in place while moving up/down page
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
vim.keymap.set("n", "n", "nzzzv") -- center screen when looping search results
|
||||
vim.keymap.set("n", "N", "Nzzzv")
|
||||
|
||||
-- paste and don't replace clipboard over deleted text
|
||||
vim.keymap.set("x", "<leader>p", [["_dP]])
|
||||
vim.keymap.set({ "n", "v" }, "<leader>d", [["_d]])
|
||||
|
||||
|
||||
-- sometimes in insert mode, control-c doesn't exactly work like escape
|
||||
vim.keymap.set("i", "<C-c>", "<Esc>")
|
||||
|
||||
-- add binds for Control J/K to scroll thru quickfix list
|
||||
vim.keymap.set("n", "<C-j>", "<cmd>cnext<CR>zz")
|
||||
vim.keymap.set("n", "<C-k>", "<cmd>cprev<CR>zz")
|
||||
|
||||
-- What the heck is Ex mode?
|
||||
vim.keymap.set("n", "Q", "<nop>")
|
||||
|
||||
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
||||
|
||||
|
||||
-- lint / format php files for LC
|
||||
vim.keymap.set("n", "<leader>cc", "<cmd>!php-cs-fixer fix % --using-cache=no<cr>")
|
||||
|
||||
-- Replace all instances of whatever is under cursor (on line)
|
||||
vim.keymap.set("n", "<leader>s", [[:s/\<<C-r><C-w>\>//gI<Left><Left><Left>]])
|
||||
|
||||
-- make file executable
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||
|
||||
-- yank into clipboard even if on ssh
|
||||
vim.keymap.set('n', '<leader>y', '<Plug>OSCYankOperator')
|
||||
vim.keymap.set('v', '<leader>y', '<Plug>OSCYankVisual')
|
||||
|
||||
-- reload without exiting vim
|
||||
vim.keymap.set("n", "<leader>rl", "<cmd>source ~/.config/nvim/init.lua<cr>")
|
||||
|
||||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
|
||||
-- Quickfix list stuff
|
||||
vim.keymap.set("n", "<leader>cl", ":cclose<CR>", { silent = true })
|
||||
vim.keymap.set("n", "<leader>co", ":copen<CR>", { silent = true })
|
||||
vim.keymap.set("n", "<leader>cn", ":cnext<CR>zz")
|
||||
vim.keymap.set("n", "<leader>cp", ":cprev<CR>zz")
|
||||
vim.keymap.set("n", "<leader>li", ":checkhealth vim.lsp<CR>", { desc = "LSP Info" })
|
||||
|
||||
-- run make in current working directory
|
||||
vim.keymap.set("n", "<leader>mm", "<cmd>make<CR>")
|
||||
|
||||
-- source file
|
||||
vim.keymap.set("n", "<leader><leader>", function()
|
||||
vim.cmd("so")
|
||||
end)
|
||||
@@ -1,55 +0,0 @@
|
||||
-- OPTIONS
|
||||
local set = vim.opt
|
||||
|
||||
--line nums
|
||||
set.relativenumber = true
|
||||
set.number = true
|
||||
|
||||
-- indentation and tabs
|
||||
set.tabstop = 4
|
||||
set.shiftwidth = 4
|
||||
set.autoindent = true
|
||||
set.expandtab = true
|
||||
|
||||
-- search settings
|
||||
set.ignorecase = true
|
||||
set.smartcase = true
|
||||
|
||||
-- appearance
|
||||
set.termguicolors = true
|
||||
set.background = "dark"
|
||||
set.signcolumn = "yes"
|
||||
|
||||
-- cursor line
|
||||
set.cursorline = true
|
||||
|
||||
-- 80th column
|
||||
set.colorcolumn = "80"
|
||||
|
||||
-- clipboard
|
||||
set.clipboard:append("unnamedplus")
|
||||
|
||||
-- backspace
|
||||
set.backspace = "indent,eol,start"
|
||||
|
||||
-- split windows
|
||||
set.splitbelow = true
|
||||
set.splitright = true
|
||||
|
||||
-- dw/diw/ciw works on full-word
|
||||
set.iskeyword:append("-")
|
||||
|
||||
-- keep cursor at least 8 rows from top/bot
|
||||
set.scrolloff = 8
|
||||
|
||||
-- undo dir settings
|
||||
set.swapfile = false
|
||||
set.backup = false
|
||||
set.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
set.undofile = true
|
||||
|
||||
-- incremental search
|
||||
set.incsearch = true
|
||||
|
||||
-- faster cursor hold
|
||||
set.updatetime = 50
|
||||
@@ -0,0 +1,211 @@
|
||||
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = false })
|
||||
|
||||
-- Diagnostic icons shown in the sign column and virtual text
|
||||
local diagnostic_signs = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = "",
|
||||
Info = "",
|
||||
}
|
||||
|
||||
-- Global diagnostic display options
|
||||
vim.diagnostic.config({
|
||||
virtual_text = { prefix = "●", spacing = 4 }, -- inline diagnostic text to the right
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = diagnostic_signs.Error,
|
||||
[vim.diagnostic.severity.WARN] = diagnostic_signs.Warn,
|
||||
[vim.diagnostic.severity.INFO] = diagnostic_signs.Info,
|
||||
[vim.diagnostic.severity.HINT] = diagnostic_signs.Hint,
|
||||
},
|
||||
},
|
||||
underline = true,
|
||||
update_in_insert = false, -- do not update diagnostics while typing (reduces noise)
|
||||
severity_sort = true, -- show errors before warnings in lists
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = "always", -- always show which LSP server produced the diagnostic
|
||||
header = "",
|
||||
prefix = "",
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
},
|
||||
})
|
||||
|
||||
-- Patch vim.lsp.util.open_floating_preview so every LSP floating window
|
||||
-- (hover, signature help, etc.) gets a rounded border without having to
|
||||
-- configure it per-server.
|
||||
do
|
||||
local orig = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or "rounded"
|
||||
return orig(contents, syntax, opts, ...)
|
||||
end
|
||||
end
|
||||
|
||||
-- lsp_on_attach is called whenever an LSP server attaches to a buffer.
|
||||
-- It sets up buffer-local keymaps that are only active when an LSP is present.
|
||||
local function lsp_on_attach(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
local bufnr = ev.buf
|
||||
local function map(key, fn, desc)
|
||||
vim.keymap.set("n", key, fn, { noremap = true, silent = true, buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map("<leader>gd", vim.lsp.buf.definition, "Go to definition")
|
||||
map("<leader>gS", function() vim.cmd("vsplit") vim.lsp.buf.definition() end, "Go to definition (vsplit)")
|
||||
|
||||
-- Code actions and refactoring
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "Code action")
|
||||
map("<leader>rn", vim.lsp.buf.rename, "Rename symbol")
|
||||
|
||||
-- Diagnostics
|
||||
map("<leader>D", function() vim.diagnostic.open_float({ scope = "line" }) end, "Line diagnostics")
|
||||
map("<leader>d", function() vim.diagnostic.open_float({ scope = "cursor" }) end, "Cursor diagnostic")
|
||||
map("<leader>nd", function() vim.diagnostic.jump({ count = 1 }) end, "Next diagnostic")
|
||||
map("<leader>pd", function() vim.diagnostic.jump({ count = -1 }) end, "Prev diagnostic")
|
||||
|
||||
-- Hover documentation
|
||||
map("K", vim.lsp.buf.hover, "Hover docs")
|
||||
|
||||
-- fzf-lua LSP pickers
|
||||
map("<leader>fd", function() require("fzf-lua").lsp_definitions({ jump_to_single_result = true }) end, "Definitions")
|
||||
map("<leader>fr", function() require("fzf-lua").lsp_references() end, "References")
|
||||
map("<leader>ft", function() require("fzf-lua").lsp_typedefs() end, "Type definitions")
|
||||
map("<leader>fs", function() require("fzf-lua").lsp_document_symbols() end, "Document symbols")
|
||||
map("<leader>fw", function() require("fzf-lua").lsp_workspace_symbols() end, "Workspace symbols")
|
||||
map("<leader>fi", function() require("fzf-lua").lsp_implementations() end, "Implementations")
|
||||
|
||||
-- Organise imports then format (only registered when the server supports codeAction)
|
||||
if client:supports_method("textDocument/codeAction", bufnr) then
|
||||
map("<leader>oi", function()
|
||||
vim.lsp.buf.code_action({
|
||||
context = { only = { "source.organizeImports" }, diagnostics = {} },
|
||||
apply = true,
|
||||
bufnr = bufnr,
|
||||
})
|
||||
-- Small delay lets the import action settle before formatting
|
||||
vim.defer_fn(function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end, 50)
|
||||
end, "Organize imports")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", { group = augroup, callback = lsp_on_attach })
|
||||
|
||||
-- Global diagnostic keymaps (available without an LSP attached)
|
||||
vim.keymap.set("n", "<leader>q", function() vim.diagnostic.setloclist({ open = true }) end, { desc = "Open diagnostic list" })
|
||||
|
||||
-- blink.cmp: completion engine wired to LuaSnip for snippet expansion
|
||||
require("blink.cmp").setup({
|
||||
enabled = function()
|
||||
return not vim.tbl_contains({ "markdown", "text" }, vim.bo.filetype)
|
||||
end,
|
||||
keymap = {
|
||||
preset = "none", -- start from a blank slate; all bindings are explicit
|
||||
["<C-Space>"] = { "show", "hide" }, -- toggle the completion menu
|
||||
["<CR>"] = { "accept", "fallback" }, -- confirm selection
|
||||
["<C-j>"] = { "select_next", "fallback" },
|
||||
["<C-k>"] = { "select_prev", "fallback" },
|
||||
["<Tab>"] = { "snippet_forward", "fallback" }, -- jump to next snippet placeholder
|
||||
["<S-Tab>"] = { "snippet_backward", "fallback" }, -- jump to previous placeholder
|
||||
},
|
||||
appearance = { nerd_font_variant = "mono" },
|
||||
completion = { menu = { auto_show = true } }, -- show the menu automatically (no manual trigger needed)
|
||||
sources = { default = { "lsp", "path", "buffer", "snippets" } },
|
||||
snippets = {
|
||||
-- Delegate snippet expansion to LuaSnip
|
||||
expand = function(snippet)
|
||||
require("luasnip").lsp_expand(snippet)
|
||||
end,
|
||||
},
|
||||
fuzzy = {
|
||||
implementation = "prefer_rust", -- use the faster Rust fuzzy-matching backend when available
|
||||
prebuilt_binaries = { download = true }, -- automatically download the pre-built binary
|
||||
},
|
||||
})
|
||||
|
||||
-- Inject blink.cmp capabilities into every LSP server so they can offer
|
||||
-- completions that respect snippet and LSP-specific completion item fields
|
||||
vim.lsp.config["*"] = {
|
||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||
}
|
||||
|
||||
-- Server configurations
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } }, -- teach lua_ls that `vim` is a known global
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.config("pyright", {}) -- Python type checker and language server
|
||||
vim.lsp.config("bashls", {}) -- Bash language server
|
||||
vim.lsp.config("vtsls", {}) -- TypeScript / JavaScript language server (VS Code's TS server)
|
||||
vim.lsp.config("gopls", {}) -- Go language server
|
||||
vim.lsp.config("omnisharp", {}) -- C# language server
|
||||
|
||||
-- EFM (efm-langserver): a generic LSP adapter that runs command-line linters
|
||||
-- and formatters and exposes them as LSP capabilities.
|
||||
do
|
||||
local luacheck = require("efmls-configs.linters.luacheck")
|
||||
local stylua = require("efmls-configs.formatters.stylua")
|
||||
local flake8 = require("efmls-configs.linters.flake8")
|
||||
local black = require("efmls-configs.formatters.black")
|
||||
local prettier_d = require("efmls-configs.formatters.prettier_d")
|
||||
local eslint_d = require("efmls-configs.linters.eslint_d")
|
||||
local fixjson = require("efmls-configs.formatters.fixjson")
|
||||
local shellcheck = require("efmls-configs.linters.shellcheck")
|
||||
local shfmt = require("efmls-configs.formatters.shfmt")
|
||||
local go_revive = require("efmls-configs.linters.go_revive")
|
||||
local gofumpt = require("efmls-configs.formatters.gofumpt")
|
||||
local csharpier = { formatCommand = "dotnet csharpier --write-stdout", formatStdin = true }
|
||||
|
||||
vim.lsp.config("efm", {
|
||||
filetypes = {
|
||||
"cs", "css", "go", "html",
|
||||
"javascript", "javascriptreact",
|
||||
"json", "jsonc",
|
||||
"lua", "markdown", "python", "sh",
|
||||
"typescript", "typescriptreact",
|
||||
},
|
||||
init_options = { documentFormatting = true },
|
||||
settings = {
|
||||
languages = {
|
||||
cs = { csharpier },
|
||||
go = { gofumpt, go_revive },
|
||||
css = { prettier_d },
|
||||
html = { prettier_d },
|
||||
javascript = { eslint_d, prettier_d },
|
||||
javascriptreact = { eslint_d, prettier_d },
|
||||
json = { eslint_d, fixjson },
|
||||
jsonc = { eslint_d, fixjson },
|
||||
lua = { luacheck, stylua },
|
||||
markdown = { prettier_d },
|
||||
python = { flake8, black },
|
||||
sh = { shellcheck, shfmt },
|
||||
typescript = { eslint_d, prettier_d },
|
||||
typescriptreact = { eslint_d, prettier_d },
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- Start all configured LSP servers
|
||||
vim.lsp.enable({
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"bashls",
|
||||
"vtsls",
|
||||
"gopls",
|
||||
"omnisharp",
|
||||
"efm",
|
||||
})
|
||||
@@ -0,0 +1,242 @@
|
||||
-- mason: GUI for installing LSP servers, DAPs, linters and formatters
|
||||
require("mason").setup({})
|
||||
|
||||
-- mason-tool-installer: automatically install all required tools on startup
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = {
|
||||
-- LSP servers
|
||||
"lua-language-server",
|
||||
"pyright",
|
||||
"bash-language-server",
|
||||
"vtsls",
|
||||
"gopls",
|
||||
"omnisharp",
|
||||
"efm",
|
||||
-- Formatters
|
||||
"stylua",
|
||||
"black",
|
||||
"prettierd",
|
||||
"shfmt",
|
||||
"gofumpt",
|
||||
"fixjson",
|
||||
-- Linters
|
||||
"flake8",
|
||||
"eslint_d",
|
||||
"shellcheck",
|
||||
"revive",
|
||||
},
|
||||
auto_update = false,
|
||||
run_on_start = true,
|
||||
})
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = false })
|
||||
|
||||
-- Diagnostic icons shown in the sign column and virtual text
|
||||
local diagnostic_signs = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = "",
|
||||
Info = "",
|
||||
}
|
||||
|
||||
-- Global diagnostic display options
|
||||
vim.diagnostic.config({
|
||||
virtual_text = { prefix = "●", spacing = 4 }, -- inline diagnostic text to the right
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = diagnostic_signs.Error,
|
||||
[vim.diagnostic.severity.WARN] = diagnostic_signs.Warn,
|
||||
[vim.diagnostic.severity.INFO] = diagnostic_signs.Info,
|
||||
[vim.diagnostic.severity.HINT] = diagnostic_signs.Hint,
|
||||
},
|
||||
},
|
||||
underline = true,
|
||||
update_in_insert = false, -- do not update diagnostics while typing (reduces noise)
|
||||
severity_sort = true, -- show errors before warnings in lists
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = "always", -- always show which LSP server produced the diagnostic
|
||||
header = "",
|
||||
prefix = "",
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
},
|
||||
})
|
||||
|
||||
-- Patch vim.lsp.util.open_floating_preview so every LSP floating window
|
||||
-- (hover, signature help, etc.) gets a rounded border without having to
|
||||
-- configure it per-server.
|
||||
do
|
||||
local orig = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or "rounded"
|
||||
return orig(contents, syntax, opts, ...)
|
||||
end
|
||||
end
|
||||
|
||||
-- lsp_on_attach is called whenever an LSP server attaches to a buffer.
|
||||
-- It sets up buffer-local keymaps that are only active when an LSP is present.
|
||||
local function lsp_on_attach(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
local bufnr = ev.buf
|
||||
local function map(key, fn, desc)
|
||||
vim.keymap.set("n", key, fn, { noremap = true, silent = true, buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map("<leader>gd", vim.lsp.buf.definition, "Go to definition")
|
||||
map("<leader>gS", function() vim.cmd("vsplit") vim.lsp.buf.definition() end, "Go to definition (vsplit)")
|
||||
|
||||
-- Code actions and refactoring
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "Code action")
|
||||
map("<leader>rn", vim.lsp.buf.rename, "Rename symbol")
|
||||
|
||||
-- Diagnostics
|
||||
map("<leader>D", function() vim.diagnostic.open_float({ scope = "line" }) end, "Line diagnostics")
|
||||
map("<leader>d", function() vim.diagnostic.open_float({ scope = "cursor" }) end, "Cursor diagnostic")
|
||||
map("<leader>nd", function() vim.diagnostic.jump({ count = 1 }) end, "Next diagnostic")
|
||||
map("<leader>pd", function() vim.diagnostic.jump({ count = -1 }) end, "Prev diagnostic")
|
||||
|
||||
-- Hover documentation
|
||||
map("K", vim.lsp.buf.hover, "Hover docs")
|
||||
|
||||
-- fzf-lua LSP pickers
|
||||
map("<leader>fd", function() require("fzf-lua").lsp_definitions({ jump_to_single_result = true }) end, "Definitions")
|
||||
map("<leader>fr", function() require("fzf-lua").lsp_references() end, "References")
|
||||
map("<leader>ft", function() require("fzf-lua").lsp_typedefs() end, "Type definitions")
|
||||
map("<leader>fs", function() require("fzf-lua").lsp_document_symbols() end, "Document symbols")
|
||||
map("<leader>fw", function() require("fzf-lua").lsp_workspace_symbols() end, "Workspace symbols")
|
||||
map("<leader>fi", function() require("fzf-lua").lsp_implementations() end, "Implementations")
|
||||
|
||||
-- Organise imports then format (only registered when the server supports codeAction)
|
||||
if client:supports_method("textDocument/codeAction", bufnr) then
|
||||
map("<leader>oi", function()
|
||||
vim.lsp.buf.code_action({
|
||||
context = { only = { "source.organizeImports" }, diagnostics = {} },
|
||||
apply = true,
|
||||
bufnr = bufnr,
|
||||
})
|
||||
-- Small delay lets the import action settle before formatting
|
||||
vim.defer_fn(function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end, 50)
|
||||
end, "Organize imports")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", { group = augroup, callback = lsp_on_attach })
|
||||
|
||||
-- Global diagnostic keymaps (available without an LSP attached)
|
||||
vim.keymap.set("n", "<leader>q", function() vim.diagnostic.setloclist({ open = true }) end, { desc = "Open diagnostic list" })
|
||||
|
||||
-- blink.cmp: completion engine wired to LuaSnip for snippet expansion
|
||||
require("blink.cmp").setup({
|
||||
enabled = function()
|
||||
return not vim.tbl_contains({ "markdown", "text" }, vim.bo.filetype)
|
||||
end,
|
||||
keymap = {
|
||||
preset = "none", -- start from a blank slate; all bindings are explicit
|
||||
["<C-Space>"] = { "show", "hide" }, -- toggle the completion menu
|
||||
["<CR>"] = { "accept", "fallback" }, -- confirm selection
|
||||
["<C-j>"] = { "select_next", "fallback" },
|
||||
["<C-k>"] = { "select_prev", "fallback" },
|
||||
["<Tab>"] = { "snippet_forward", "fallback" }, -- jump to next snippet placeholder
|
||||
["<S-Tab>"] = { "snippet_backward", "fallback" }, -- jump to previous placeholder
|
||||
},
|
||||
appearance = { nerd_font_variant = "mono" },
|
||||
completion = { menu = { auto_show = true } }, -- show the menu automatically (no manual trigger needed)
|
||||
sources = { default = { "lsp", "path", "buffer", "snippets" } },
|
||||
snippets = {
|
||||
-- Delegate snippet expansion to LuaSnip
|
||||
expand = function(snippet)
|
||||
require("luasnip").lsp_expand(snippet)
|
||||
end,
|
||||
},
|
||||
fuzzy = {
|
||||
implementation = "prefer_rust", -- use the faster Rust fuzzy-matching backend when available
|
||||
prebuilt_binaries = { download = true }, -- automatically download the pre-built binary
|
||||
},
|
||||
})
|
||||
|
||||
-- Inject blink.cmp capabilities into every LSP server so they can offer
|
||||
-- completions that respect snippet and LSP-specific completion item fields
|
||||
vim.lsp.config["*"] = {
|
||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||
}
|
||||
|
||||
-- Server configurations
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } }, -- teach lua_ls that `vim` is a known global
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.config("pyright", {}) -- Python type checker and language server
|
||||
vim.lsp.config("bashls", {}) -- Bash language server
|
||||
vim.lsp.config("vtsls", {}) -- TypeScript / JavaScript language server (VS Code's TS server)
|
||||
vim.lsp.config("gopls", {}) -- Go language server
|
||||
vim.lsp.config("omnisharp", {}) -- C# language server
|
||||
|
||||
-- EFM (efm-langserver): a generic LSP adapter that runs command-line linters
|
||||
-- and formatters and exposes them as LSP capabilities.
|
||||
do
|
||||
local luacheck = require("efmls-configs.linters.luacheck")
|
||||
local stylua = require("efmls-configs.formatters.stylua")
|
||||
local flake8 = require("efmls-configs.linters.flake8")
|
||||
local black = require("efmls-configs.formatters.black")
|
||||
local prettier_d = require("efmls-configs.formatters.prettier_d")
|
||||
local eslint_d = require("efmls-configs.linters.eslint_d")
|
||||
local fixjson = require("efmls-configs.formatters.fixjson")
|
||||
local shellcheck = require("efmls-configs.linters.shellcheck")
|
||||
local shfmt = require("efmls-configs.formatters.shfmt")
|
||||
local go_revive = require("efmls-configs.linters.go_revive")
|
||||
local gofumpt = require("efmls-configs.formatters.gofumpt")
|
||||
local csharpier = { formatCommand = "dotnet csharpier --write-stdout", formatStdin = true }
|
||||
|
||||
vim.lsp.config("efm", {
|
||||
filetypes = {
|
||||
"cs", "css", "go", "html",
|
||||
"javascript", "javascriptreact",
|
||||
"json", "jsonc",
|
||||
"lua", "markdown", "python", "sh",
|
||||
"typescript", "typescriptreact",
|
||||
},
|
||||
init_options = { documentFormatting = true },
|
||||
settings = {
|
||||
languages = {
|
||||
cs = { csharpier },
|
||||
go = { gofumpt, go_revive },
|
||||
css = { prettier_d },
|
||||
html = { prettier_d },
|
||||
javascript = { eslint_d, prettier_d },
|
||||
javascriptreact = { eslint_d, prettier_d },
|
||||
json = { eslint_d, fixjson },
|
||||
jsonc = { eslint_d, fixjson },
|
||||
lua = { luacheck, stylua },
|
||||
markdown = { prettier_d },
|
||||
python = { flake8, black },
|
||||
sh = { shellcheck, shfmt },
|
||||
typescript = { eslint_d, prettier_d },
|
||||
typescriptreact = { eslint_d, prettier_d },
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- Start all configured LSP servers
|
||||
vim.lsp.enable({
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"bashls",
|
||||
"vtsls",
|
||||
"gopls",
|
||||
"omnisharp",
|
||||
"efm",
|
||||
})
|
||||
@@ -1,36 +0,0 @@
|
||||
local M = {}
|
||||
local plug_dir = vim.fn.stdpath("data") .. "/plugins"
|
||||
|
||||
local function ensure(spec)
|
||||
local repo = type(spec) == "string" and spec or spec[1]
|
||||
local name = repo:match(".+/(.+)$")
|
||||
local path = plug_dir .. "/" .. name
|
||||
|
||||
if not vim.uv.fs_stat(path) then
|
||||
vim.fn.mkdir(plug_dir, "p")
|
||||
local cmd = { "git", "clone", "--depth=1" }
|
||||
if spec.branch then
|
||||
table.insert(cmd, "-b")
|
||||
table.insert(cmd, spec.branch)
|
||||
end
|
||||
table.insert(cmd, "https://github.com/" .. repo)
|
||||
table.insert(cmd, path)
|
||||
print("Installing " .. name .. "...")
|
||||
vim.fn.system(cmd)
|
||||
end
|
||||
|
||||
vim.opt.rtp:prepend(path)
|
||||
vim.opt.rtp:append(path .. "/after")
|
||||
local lua_path = path .. "/lua"
|
||||
if vim.uv.fs_stat(lua_path) then
|
||||
package.path = package.path .. ";" .. lua_path .. "/?.lua;" .. lua_path .. "/?/init.lua"
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
for _, spec in ipairs(require("plugin-list")) do
|
||||
ensure(spec)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,17 +0,0 @@
|
||||
return {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
{ "ThePrimeagen/harpoon", branch = "harpoon2" },
|
||||
"folke/tokyonight.nvim",
|
||||
"nvim-lualine/lualine.nvim",
|
||||
"brenoprata10/nvim-highlight-colors",
|
||||
"tpope/vim-fugitive",
|
||||
"mbbill/undotree",
|
||||
"ojroques/vim-oscyank",
|
||||
"captbaritone/better-indent-support-for-php-with-html",
|
||||
}
|
||||
Reference in New Issue
Block a user