diff options
author | Dennis Eriksen <d@ennis.no> | 2024-04-04 09:59:44 +0200 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2024-04-04 09:59:44 +0200 |
commit | af73a1265342c55dcd41a3c954420c9fb9a07e55 (patch) | |
tree | 72e91d25c43ffa11f18133b14f05b9593f016d22 | |
parent | move npm-files to XDG (diff) | |
download | idgatt-af73a1265342c55dcd41a3c954420c9fb9a07e55.tar.gz |
change how some stuff are loaded, and add some file headers
-rw-r--r-- | config/.config/nvim/lua/plugins/langs/go.lua | 140 | ||||
-rw-r--r-- | config/.config/nvim/lua/plugins/langs/lua.lua | 6 | ||||
-rw-r--r-- | config/.config/nvim/lua/plugins/langs/python.lua | 6 | ||||
-rw-r--r-- | config/.config/nvim/lua/plugins/langs/rust.lua | 83 | ||||
-rw-r--r-- | config/.config/nvim/lua/plugins/langs/shell.lua | 6 | ||||
-rw-r--r-- | config/.config/nvim/lua/plugins/langs/yaml_ansible.lua | 2 |
6 files changed, 147 insertions, 96 deletions
diff --git a/config/.config/nvim/lua/plugins/langs/go.lua b/config/.config/nvim/lua/plugins/langs/go.lua index 983f245..a043dab 100644 --- a/config/.config/nvim/lua/plugins/langs/go.lua +++ b/config/.config/nvim/lua/plugins/langs/go.lua @@ -1,4 +1,10 @@ -return { +-- +-- Author : Dennis Eriksen <d@ennis.no> +-- File : go.lua +-- Created : 2024-02-15 +-- + +local M = { { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -10,72 +16,80 @@ return { }) end, }, - { - "neovim/nvim-lspconfig", - opts = { - servers = { - gopls = { - mason = false, -- install gopls outside of Mason - settings = { - gopls = { - gofumpt = false, - codelenses = { - gc_details = false, - generate = true, - regenerate_cgo = true, - run_govulncheck = true, - test = true, - tidy = true, - upgrade_dependency = true, - vendor = true, - }, - hints = { - assignVariableTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - constantValues = true, - functionTypeParameters = true, - parameterNames = true, - rangeVariableTypes = true, - }, - analyses = { - fieldalignment = true, - nilness = true, - unusedparams = true, - unusedwrite = true, - useany = true, +} + +-- Don't bother with lsp unless go is installed +if vim.fn.executable("go") == 1 and vim.fn.executable("gopls") == 1 then + table.insert(M, { + { + "neovim/nvim-lspconfig", + opts = { + servers = { + gopls = { + mason = false, -- install gopls outside of Mason + settings = { + gopls = { + gofumpt = false, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + semanticTokens = true, }, - usePlaceholders = true, - completeUnimported = true, - staticcheck = true, - directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, - semanticTokens = true, }, }, }, - }, - setup = { - gopls = function(_, opts) - -- workaround for gopls not supporting semanticTokensProvider - -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 - require("lazyvim.util").lsp.on_attach(function(client, _) - if client.name == "gopls" then - if not client.server_capabilities.semanticTokensProvider then - local semantic = client.config.capabilities.textDocument.semanticTokens - client.server_capabilities.semanticTokensProvider = { - full = true, - legend = { - tokenTypes = semantic.tokenTypes, - tokenModifiers = semantic.tokenModifiers, - }, - range = true, - } + setup = { + gopls = function(_, opts) + -- workaround for gopls not supporting semanticTokensProvider + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + require("lazyvim.util").lsp.on_attach(function(client, _) + if client.name == "gopls" then + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end end - end - end) - -- end workaround - end, + end) + -- end workaround + end, + }, }, }, - }, -} + }) +end + +return M diff --git a/config/.config/nvim/lua/plugins/langs/lua.lua b/config/.config/nvim/lua/plugins/langs/lua.lua index 3dae708..2c7855a 100644 --- a/config/.config/nvim/lua/plugins/langs/lua.lua +++ b/config/.config/nvim/lua/plugins/langs/lua.lua @@ -1,3 +1,9 @@ +-- +-- Author : Dennis Eriksen <d@ennis.no> +-- File : lua.lua +-- Created : 2024-02-15 +-- + local M = { { -- https://github.com/stevearc/conform.nvim "stevearc/conform.nvim", diff --git a/config/.config/nvim/lua/plugins/langs/python.lua b/config/.config/nvim/lua/plugins/langs/python.lua index 4f1c732..c6b383f 100644 --- a/config/.config/nvim/lua/plugins/langs/python.lua +++ b/config/.config/nvim/lua/plugins/langs/python.lua @@ -1,3 +1,9 @@ +-- +-- Author : Dennis Eriksen <d@ennis.no> +-- File : python.lua +-- Created : 2024-02-15 +-- + return { { -- https://github.com/neovim/nvim-lspconfig "neovim/nvim-lspconfig", diff --git a/config/.config/nvim/lua/plugins/langs/rust.lua b/config/.config/nvim/lua/plugins/langs/rust.lua index 13086f3..f9f428e 100644 --- a/config/.config/nvim/lua/plugins/langs/rust.lua +++ b/config/.config/nvim/lua/plugins/langs/rust.lua @@ -1,26 +1,10 @@ --- rust-analyzer isn't packaged for OpenBSD yet, so drop it on OpenBSD. +-- +-- Author : Dennis Eriksen <d@ennis.no> +-- File : rust.lua +-- Created : 2024-02-15 +-- local M = { - -- Extend auto completion - { - "hrsh7th/nvim-cmp", - dependencies = { - { - "Saecki/crates.nvim", - event = { "BufRead Cargo.toml" }, - opts = { - src = { - cmp = { enabled = true }, - }, - }, - }, - }, - opts = function(_, opts) - opts.sources = opts.sources or {} - table.insert(opts.sources, { name = "crates" }) - end, - }, - -- Add Rust & related to treesitter { "nvim-treesitter/nvim-treesitter", @@ -30,22 +14,57 @@ local M = { end end, }, +} + +-- return if rustc isn't available +if vim.fn.executable("cargo") ~= 1 then + return M +end + + -- if rust-analyzer is available +if vim.fn.executable("cargo") == 1 then + table.insert(M, { + -- Extend auto completion + { + "hrsh7th/nvim-cmp", + dependencies = { + { + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + src = { + cmp = { enabled = true }, + }, + }, + }, + }, + opts = function(_, opts) + opts.sources = opts.sources or {} + table.insert(opts.sources, { name = "crates" }) + end, + }, + }) +end - -- Formatting - { -- https://github.com/stevearc/conform.nvim - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - rust = { "rustfmt" }, +-- if rust-analyzer is available +if vim.fn.executable("rustfmt") == 1 then + table.insert(M, { + -- Formatting + { -- https://github.com/stevearc/conform.nvim + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + rust = { "rustfmt" }, + }, }, }, - }, -} + }) +end --- if NOT OpenBSD -if vim.loop.os_uname().sysname ~= "OpenBSD" then +-- if rust-analyzer is available +if vim.fn.executable("rust-analyzer") == 1 then table.insert(M, { - { + { -- https://github.com/neovim/nvim-lspconfig "neovim/nvim-lspconfig", opts = { servers = { diff --git a/config/.config/nvim/lua/plugins/langs/shell.lua b/config/.config/nvim/lua/plugins/langs/shell.lua index 27ca791..0391c6e 100644 --- a/config/.config/nvim/lua/plugins/langs/shell.lua +++ b/config/.config/nvim/lua/plugins/langs/shell.lua @@ -1,3 +1,9 @@ +-- +-- Author : Dennis Eriksen <d@ennis.no> +-- File : shell.lua +-- Created : 2024-02-15 +-- + local fmts = {} if vim.loop.os_uname().sysname ~= "OpenBSD" then fmts = { diff --git a/config/.config/nvim/lua/plugins/langs/yaml_ansible.lua b/config/.config/nvim/lua/plugins/langs/yaml_ansible.lua index 20fc45d..234d067 100644 --- a/config/.config/nvim/lua/plugins/langs/yaml_ansible.lua +++ b/config/.config/nvim/lua/plugins/langs/yaml_ansible.lua @@ -1,6 +1,6 @@ -- -- Author : Dennis Eriksen <d@ennis.no> --- File : perl.lua +-- File : yaml_ansible.lua -- Created : 2024-02-15 -- |