summaryrefslogtreecommitdiff
path: root/lua/ben
diff options
context:
space:
mode:
Diffstat (limited to 'lua/ben')
-rw-r--r--lua/ben/lazy.lua1
-rw-r--r--lua/ben/plugins/fugitive.lua28
-rw-r--r--lua/ben/plugins/lf.lua2
-rw-r--r--lua/ben/plugins/lsp.lua246
-rw-r--r--lua/ben/plugins/lsp/mason.lua72
5 files changed, 261 insertions, 88 deletions
diff --git a/lua/ben/lazy.lua b/lua/ben/lazy.lua
index e363abb..46668e4 100644
--- a/lua/ben/lazy.lua
+++ b/lua/ben/lazy.lua
@@ -12,7 +12,6 @@ end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{ import = "ben.plugins" },
- { import = "ben.plugins.lsp" },
}, {
install = {
colorscheme = { "everforest" },
diff --git a/lua/ben/plugins/fugitive.lua b/lua/ben/plugins/fugitive.lua
index 4b73c42..051a983 100644
--- a/lua/ben/plugins/fugitive.lua
+++ b/lua/ben/plugins/fugitive.lua
@@ -17,20 +17,20 @@ return {
},
config = function()
-- Use > and < to fix merge conflicts (keep the cursor in the middle of the screen)
- vim.api.nvim_set_keymap("n", ">", "<cmd>diffg //2<cr><cmd>diffupdate<cr>", { noremap = true, silent = true })
- vim.api.nvim_set_keymap("n", "<", "<cmd>diffg //3<cr><cmd>diffupdate<cr>", { noremap = true, silent = true })
+ -- vim.api.nvim_set_keymap("n", ">", "<cmd>diffg //2<cr><cmd>diffupdate<cr>", { noremap = true, silent = true })
+ -- vim.api.nvim_set_keymap("n", "<", "<cmd>diffg //3<cr><cmd>diffupdate<cr>", { noremap = true, silent = true })
-- Use } and { to force the entire file
- vim.api.nvim_set_keymap(
- "n",
- "}",
- "<C-w>h<cmd>Gwrite!<cr><cmd>diffupdate<cr>",
- { noremap = true, silent = true }
- )
- vim.api.nvim_set_keymap(
- "n",
- "{",
- "<C-w>l<cmd>Gwrite!<cr><cmd>diffupdate<cr>",
- { noremap = true, silent = true }
- )
+ -- vim.api.nvim_set_keymap(
+ -- "n",
+ -- "}",
+ -- "<C-w>h<cmd>Gwrite!<cr><cmd>diffupdate<cr>",
+ -- { noremap = true, silent = true }
+ -- )
+ -- vim.api.nvim_set_keymap(
+ -- "n",
+ -- "{",
+ -- "<C-w>l<cmd>Gwrite!<cr><cmd>diffupdate<cr>",
+ -- { noremap = true, silent = true }
+ -- )
end,
}
diff --git a/lua/ben/plugins/lf.lua b/lua/ben/plugins/lf.lua
index 2e28de2..5c95197 100644
--- a/lua/ben/plugins/lf.lua
+++ b/lua/ben/plugins/lf.lua
@@ -6,7 +6,7 @@ return {
},
config = function()
vim.g.lf_netrw = 1
- require("lf").setup({
+ local lf = require("lf").setup({
border = "rounded",
focus_on_open = true,
})
diff --git a/lua/ben/plugins/lsp.lua b/lua/ben/plugins/lsp.lua
new file mode 100644
index 0000000..251a459
--- /dev/null
+++ b/lua/ben/plugins/lsp.lua
@@ -0,0 +1,246 @@
+return {
+
+ {
+ "williamboman/mason.nvim",
+ dependencies = {
+ "williamboman/mason-lspconfig.nvim",
+ "WhoIsSethDaniel/mason-tool-installer.nvim",
+ },
+ 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({
+ ui = {
+ icons = {
+ package_installed = "",
+ package_pending = "",
+ package_uninstalled = "",
+ },
+ },
+ })
+
+ mason_lspconfig.setup({
+ -- list of servers for mason to install
+ ensure_installed = {
+ "ast_grep", -- fallback
+ "lua_ls", -- lua
+ "autotools_ls", -- Makefile
+ "dockerls", -- dockerfiles
+ "docker_compose_language_service", -- docker-compose
+ "marksman", -- markdown
+ "gopls", -- go
+ "texlab", -- latex
+ "pyre", -- python
+ "r_language_server", -- r
+ "rust_analyzer", -- rust
+ "mutt_ls", -- mutt
+ "taplo", -- toml
+ "yamlls", -- yaml
+ },
+ -- auto-install configured servers (with lspconfig)
+ automatic_installation = true,
+ })
+
+ -- configure mason tool installer
+ mason_tool_installer.setup({
+ ensure_installed = {
+ "isort", -- python import formatter
+ "goimports", -- go import formatter
+ "doctoc", -- markdown table of contents generator
+ "go-debug-adapter", -- go debugger
+ "codelldb", -- c/c++ debugger
+ },
+ })
+ end,
+ },
+
+ {
+ "neovim/nvim-lspconfig",
+ dependencies = { "hrsh7th/cmp-nvim-lsp" },
+ event = { "BufReadPre", "BufNewFile" },
+ config = function()
+ -- import lspconfig plugin
+ local lspconfig = require("lspconfig")
+
+ -- import cmp-nvim-lsp plugin
+ local cmp_nvim_lsp = require("cmp_nvim_lsp")
+
+ local keymap = vim.keymap
+
+ local opts = { noremap = true, silent = true }
+ local on_attach = function(client, bufnr)
+ opts.buffer = bufnr
+
+ -- set keybinds
+ opts.desc = "Show LSP references"
+ keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
+
+ opts.desc = "Go to declaration"
+ keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
+
+ opts.desc = "Show LSP definitions"
+ keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
+
+ opts.desc = "Show LSP implementations"
+ keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
+
+ opts.desc = "Show LSP type definitions"
+ keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
+
+ opts.desc = "See available code actions"
+ keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
+
+ opts.desc = "Smart rename"
+ keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
+
+ opts.desc = "Show buffer diagnostics"
+ keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
+
+ opts.desc = "Show line diagnostics"
+ keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
+
+ opts.desc = "Go to previous diagnostic"
+ keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
+
+ opts.desc = "Go to next diagnostic"
+ keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagostic in buffer
+
+ opts.desc = "Show documentation for what is under cursor"
+ keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
+
+ opts.desc = "Restart LSP"
+ keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
+ end
+
+ -- used to enable autocompletion (assign to every lsp server config)
+ local capabilities = cmp_nvim_lsp.default_capabilities()
+
+ -- change diagnostic symbols in sign column
+ local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " }
+ for type, icon in pairs(signs) do
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
+ end
+
+ -- configure lua server (with special settings)
+ lspconfig["lua_ls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ settings = { -- custom settings for lua
+ Lua = {
+ -- make the language server recognize "vim" global
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ -- make language server aware of runtime files
+ library = {
+ [vim.fn.expand("$VIMRUNTIME/lua")] = true,
+ [vim.fn.stdpath("config") .. "/lua"] = true,
+ },
+ },
+ },
+ },
+ })
+
+ -- configure dockerfile server
+ lspconfig["dockerls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure docker-compose server
+ lspconfig["docker_compose_language_service"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure markdown server
+ lspconfig["marksman"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure golang server
+ lspconfig["gopls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure LaTeX server
+ lspconfig["texlab"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure LaTeX server
+ lspconfig["texlab"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure python server
+ lspconfig["pyre"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure R server
+ lspconfig["r_language_server"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure R server
+ lspconfig["r_language_server"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure mutt server
+ lspconfig["mutt_ls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure toml server
+ lspconfig["taplo"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure Makefile server
+ lspconfig["autotools_ls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure fallback server
+ lspconfig["ast_grep"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure yaml server
+ lspconfig["yamlls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ settings = {
+ yaml = {
+ schemas = {
+ ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
+ ["../path/relative/to/file.yml"] = "/.github/workflows/*",
+ ["/path/from/root/of/project"] = "/.github/workflows/*",
+ },
+ },
+ },
+ })
+ end,
+ },
+}
diff --git a/lua/ben/plugins/lsp/mason.lua b/lua/ben/plugins/lsp/mason.lua
deleted file mode 100644
index 121509d..0000000
--- a/lua/ben/plugins/lsp/mason.lua
+++ /dev/null
@@ -1,72 +0,0 @@
-return {
- "williamboman/mason.nvim",
- dependencies = {
- "williamboman/mason-lspconfig.nvim",
- "WhoIsSethDaniel/mason-tool-installer.nvim",
- },
- 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({
- ui = {
- icons = {
- package_installed = "",
- package_pending = "",
- package_uninstalled = "",
- },
- },
- })
- mason_lspconfig.setup({
- -- list of servers for mason to install
- ensure_installed = {
- "bashls",
- "cssls",
- "diagnosticls",
- "dockerls",
- "docker_compose_language_service",
- "gopls",
- "lua_ls",
- "texlab",
- "zk",
- "pyright",
- "r_language_server",
- "sqls",
- },
- -- auto-install configured servers (with lspconfig)
- automatic_installation = true, -- not the same as ensure_installed
- })
-
- mason_tool_installer.setup({
- ensure_installed = {
- "mutt-language-server",
- "emmet-ls",
- -- Linters:
- "prettier",
- "bibtex-tidy",
- "goimports",
- "gci",
- "golines",
- "shfmt",
- "latexindent",
- "sql-formatter",
- "isort",
- "black",
- "yamlfix",
- "stylua",
- -- Formatters:
- "stylelint",
- "markdownlint",
- "pylint",
- "golangci-lint",
- "shellcheck",
- },
- })
-
- end,
-}