15 files changed,
237 insertions(+),
156 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2025-05-15 19:49:28 +0300
Parent:
83e9ecd
jump to
A
after/ftplugin/ledger.lua
@@ -0,0 +1,3 @@
+vim.opt_local.foldmethod = "marker" +vim.opt_local.ts = 2 +vim.opt_local.sw = 2
M
init.lua
@@ -2,4 +2,5 @@ require "core.options"
require "core.lazy" require "core.keymaps" require "core.autocmd" +require "core.lsp" require "hidden"
A
lsp/golangci_lint_ls.lua
@@ -0,0 +1,21 @@
+local u = require("core.utils").lsp + +---@return vim.lsp.Config +return { + cmd = { "golangci-lint-langserver" }, + filetypes = { "go", "gomod" }, + init_options = { + command = { + "golangci-lint", + "run", + "--output.json.path=stdout", + "--show-stats=false", + }, + }, + root_markers = u.root_marker { + ".golangci.yml", + ".golangci.yaml", + ".golangci.toml", + ".golangci.json", + }, +}
A
lsp/gopls.lua
@@ -0,0 +1,43 @@
+local u = require("core.utils").lsp + +---@return vim.lsp.Config +return { + cmd = { "gopls" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + root_markers = u.root_marker { + "go.mod", + "go.work", + }, + settings = { + gopls = { + linksInHover = false, + staticcheck = true, + gofumpt = true, + analyses = { + unusedparams = true, + unreachable = true, + unusedwrite = true, + useany = true, + shadow = true, + nilness = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = false, + parameterNames = true, + rangeVariableTypes = true, + }, + codelenses = { + generate = true, + gc_details = false, + test = true, + tidy = true, + run_govulncheck = true, + upgrade_dependency = true, + }, + }, + }, +}
A
lsp/jsonls.lua
@@ -0,0 +1,14 @@
+---@return vim.lsp.Config +return { + cmd = { "vscode-json-language-server", "--stdio" }, + filetypes = { "json", "jsonc" }, + init_options = { + provideFormatter = true, + }, + settings = { + json = { + schemas = require("schemastore").json.schemas(), + validate = { enable = true }, + }, + }, +}
A
lsp/lua_ls.lua
@@ -0,0 +1,31 @@
+---@return vim.lsp.Config +return { + cmd = { "lua-language-server" }, + filetypes = { "lua" }, + root_markers = { + ".luarc.json", + ".luarc.jsonc", + ".luacheckrc", + ".stylua.toml", + "stylua.toml", + "selene.toml", + "selene.yml", + ".git", + }, + settings = { + Lua = { + format = { enable = false }, + completion = { callSnippet = "Replace" }, + telemetry = { enable = false }, + hint = { + enable = true, + arrayIndex = "Disable", + await = true, + paramName = "Disable", + paramType = false, + semicolon = "Disable", + setType = true, + }, + }, + }, +}
A
lsp/markdown_oxide.lua
@@ -0,0 +1,15 @@
+local u = require("core.utils").lsp + +---@return vim.lsp.Config +return { + cmd = { "markdown-oxide" }, + filetypes = { "markdown" }, + root_markers = { ".git", ".obsidian", ".moxide.toml" }, + capabilities = u.capabilities { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + }, + }, +}
A
lsp/yamlls.lua
@@ -0,0 +1,12 @@
+---@return vim.lsp.Config +return { + cmd = { "yaml-language-server", "--stdio" }, + filetypes = { "yaml", "yaml.docker-compose", "yaml.gitlab" }, + settings = { + redhat = { telemetry = { enabled = false } }, + yaml = { + schemaStore = { enable = false, url = "" }, + schemas = require("schemastore").yaml.schemas(), + }, + }, +}
M
lua/core/utils.lua
@@ -1,3 +1,5 @@
+local lsp_root_markers = { ".git" } + return { ---@param mode string|table ---@param from string@@ -12,7 +14,36 @@ })
end, aucmd = vim.api.nvim_create_autocmd, + + ---@param name string + ---@return integer augroup = function(name) return vim.api.nvim_create_augroup("olexsmir_" .. name, { clear = true }) end, + + lsp = { + default_markers = lsp_root_markers, + + ---@param extend? string[] + root_marker = function(extend) + if extend == nil then + return lsp_root_markers + end + + local r = vim.deepcopy(lsp_root_markers) + for _, v in ipairs(extend) do + table.insert(r, v) + end + return r + end, + + ---@param extend? table + capabilities = function(extend) + return vim.tbl_extend( + "force", + vim.lsp.protocol.make_client_capabilities(), + extend or {} + ) + end, + }, }
M
lua/plugins/git.lua
@@ -47,7 +47,9 @@ cmd = "Neogit",
keys = { { "<leader>gg", vim.cmd.Neogit } }, ---@module "neogit" ---@type NeogitConfig - dependencies = { "sindrets/diffview.nvim" }, + dependencies = { + { "sindrets/diffview.nvim", cmd = "DiffviewOpen" }, + }, opts = { kind = "vsplit", console_timeout = 8000,
M
lua/core/lsp.lua
→lua/core/lsp.lua
@@ -1,5 +1,19 @@
local u = require "core.utils" +vim.lsp.config("*", { + root_markers = u.lsp.default_markers, + flags = { debounce_text_changes = 150 }, +}) + +vim.lsp.enable { + "golangci_lint_ls", + "gopls", + "jsonls", + "lua_ls", + "markdown_oxide", + "yamlls", +} + u.aucmd("LspAttach", { group = u.augroup "lsp", callback = function(args)
M
lua/plugins/lsp/init.lua
@@ -1,60 +1,57 @@
---@type LazySpec return { - "neovim/nvim-lspconfig", - event = "BufRead", - dependencies = { - "b0o/schemastore.nvim", - { import = "plugins.lsp.lazydev" }, - { import = "plugins.lsp.null-ls" }, - { - "j-hui/fidget.nvim", - dependencies = { "nvim-lspconfig" }, - opts = { - progress = { - display = { - render_limit = 2, - done_ttl = 2, - }, + "b0o/schemastore.nvim", + { import = "plugins.lsp.lazydev" }, + { import = "plugins.lsp.null-ls" }, + + { + "j-hui/fidget.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + progress = { + display = { + render_limit = 2, + done_ttl = 2, }, }, }, - { - "nvim-cmp", - dependencies = { "hrsh7th/cmp-nvim-lsp" }, - ---@module "cmp" - ---@param opts cmp.ConfigSchema - opts = function(_, opts) - table.insert(opts.sources, 1, { - name = "nvim_lsp", - group_index = 0, - max_item_count = 12, - }) - end, + }, + + { + "RRethy/vim-illuminate", + event = { "BufReadPre", "BufNewFile" }, + opts = { + providers = { "lsp", "treesitter" }, + filetypes_denylist = { + "NeogitStatus", + "TelescopePrompt", + }, }, - { - "RRethy/vim-illuminate", - dependencies = { "nvim-lspconfig" }, - opts = { - providers = { "lsp", "treesitter" }, - filetypes_denylist = { - "NvimTree", - "packer", - "NeogitStatus", - "TelescopePrompt", - }, + config = function(_, opts) + require("illuminate").configure(opts) + end, + }, + + { + "nvim-cmp", + dependencies = { + { + "hrsh7th/cmp-nvim-lsp", + config = function() + vim.lsp.config("*", { + capabilities = require("cmp_nvim_lsp").default_capabilities(), + }) + end, }, - config = function(_, opts) - require("illuminate").configure(opts) - end, }, + ---@module "cmp" + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + table.insert(opts.sources, 1, { + name = "nvim_lsp", + group_index = 0, + max_item_count = 12, + }) + end, }, - config = function() - for name, conf in pairs(require "plugins.lsp.servers") do - require "plugins.lsp.attach" - require("lspconfig")[name].setup(vim.tbl_extend("force", { - flags = { debounce_text_changes = 150 }, - capabilities = require("cmp_nvim_lsp").default_capabilities(), - }, conf)) - end - end, }
M
lua/plugins/lsp/lazydev.lua
@@ -4,7 +4,6 @@ "folke/lazydev.nvim",
ft = "lua", cmd = "LazyDev", dependencies = { - "nvim-lspconfig", { "nvim-cmp", ---@module "cmp"
M
lua/plugins/lsp/null-ls.lua
@@ -1,7 +1,7 @@
---@type LazySpec return { "nvimtools/none-ls.nvim", - dependencies = { "nvim-lspconfig" }, + event = { "BufReadPre", "BufNewFile" }, config = function() local null_ls = require "null-ls" local formatting = null_ls.builtins.formatting@@ -9,6 +9,7 @@ local diagnostic = null_ls.builtins.diagnostics
null_ls.setup { sources = { + formatting.pg_format, diagnostic.codespell.with { args = { "--ignore-words",@@ -26,13 +27,6 @@ },
formatting.goimports, formatting.golines, - - formatting.clang_format, - formatting.pg_format, - formatting.prettierd.with { - -- stylua: ignore - filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "html", "json", "jsonc", "svelte", "astro" }, - }, }, } end,
D
@@ -1,96 +0,0 @@
-return { - clangd = {}, - eslint = {}, - html = {}, - gleam = {}, - templ = {}, - bashls = {}, - gopls = { - settings = { - gopls = { - linksInHover = false, - staticcheck = true, - gofumpt = true, - analyses = { - unusedparams = true, - unreachable = true, - unusedwrite = true, - useany = true, - shadow = true, - nilness = true, - }, - hints = { - assignVariableTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - constantValues = true, - functionTypeParameters = false, - parameterNames = true, - rangeVariableTypes = true, - }, - codelenses = { - generate = true, - gc_details = false, - test = true, - tidy = true, - run_govulncheck = true, - upgrade_dependency = true, - }, - }, - }, - }, - golangci_lint_ls = { - init_options = { - command = { - "golangci-lint", - "run", - "--output.json.path=stdout", - "--show-stats=false", - "--issues-exit-code=1", - }, - }, - }, - lua_ls = { - settings = { - Lua = { - format = { enable = false }, - completion = { callSnippet = "Replace" }, - telemetry = { enable = false }, - hint = { - enable = true, - arrayIndex = "Disable", - await = true, - paramName = "Disable", - paramType = false, - semicolon = "Disable", - setType = true, - }, - }, - }, - }, - markdown_oxide = { - capabilities = { - workspace = { - didChangeWatchedFiles = { - dynamicRegistration = true, - }, - }, - }, - }, - yamlls = { - settings = { - yaml = { - schemaStore = { enable = false, url = "" }, - schemas = require("schemastore").yaml.schemas(), - }, - }, - }, - jsonls = { - settings = { - json = { - schemas = require("schemastore").json.schemas(), - validate = { enable = true }, - }, - }, - }, -}