summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-01 12:32:15 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-01 12:46:03 +0200
commit392d3df314874fe802d51f84e3a63f82a8ab893b (patch)
treef8cfbd92339eb40a8fb8fd8aea29bad46e3ac0c5
parent08fe2898811816fd0a096e6996d8ed25d2e940c8 (diff)
Changes to snippets, lsp, lazy and set.lua
- Changed go snippets to be more intuitive - lazy.lua: - Added lsp_signature plugin - Added which-keky plugin - lsp.lua: - Changed lsp.lua to have variables at the top - Added more keybinds for diagnostics - Added gopls configuration for inlay hints - Moved borders from set.lua to lsp.lua - Added ts_ls and powershell lsps - set.lua: - Added colorcolumn option - luasnip.lua: - Added shebang snippet for shell
-rw-r--r--after/ftplugin/sh.lua3
-rw-r--r--after/plugin/luasnip.lua12
-rw-r--r--lua/config/lazy.lua29
-rw-r--r--lua/config/lsp.lua139
-rw-r--r--lua/config/set.lua13
5 files changed, 130 insertions, 66 deletions
diff --git a/after/ftplugin/sh.lua b/after/ftplugin/sh.lua
new file mode 100644
index 0000000..2cb8493
--- /dev/null
+++ b/after/ftplugin/sh.lua
@@ -0,0 +1,3 @@
+local map = vim.keymap.set
+
+map("n", ",v", [[<cmd>s/\(\s*\)\(.\+\)/\1"$(\2)"/<cr>]])
diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua
index 3a64f9a..c7ee31b 100644
--- a/after/plugin/luasnip.lua
+++ b/after/plugin/luasnip.lua
@@ -25,14 +25,14 @@ ls.config.set_config({
history = true,
})
-ls.add_snippets("all", {
- ls.parser.parse_snippet("test", "$1->$2->$3->$0\n"),
-})
ls.add_snippets("go", {
ls.parser.parse_snippet("main", "package main\n\nfunc main() {\n\t$0\n}"),
- ls.parser.parse_snippet("e", "if err != nil {\n\t$1\n}\n$0"),
- ls.parser.parse_snippet("ep", "if err != nil {\n\tpanic(err)\n}\n$0"),
- ls.parser.parse_snippet("eif", "if err := $1; err != nil {\n\tpanic(err)\n}\n$0"),
+ ls.parser.parse_snippet("e", "if err != nil {\n\tfmt.Println(err)$1\n}\n$0"),
+ ls.parser.parse_snippet("ee", "if err != nil {\n\tfmt.Println(err)$1\n\tos.Exit(${2:1})\n}\n$0"),
+ ls.parser.parse_snippet("eif", "if err := $1; err != nil {\n\tfmt.Println(err)$2\n}\n$0"),
ls.parser.parse_snippet("pf", "fmt.Printf($0)"),
ls.parser.parse_snippet("pl", "fmt.Println($0)"),
})
+ls.add_snippets("sh", {
+ ls.parser.parse_snippet("!", "#!/bin/sh\n$0"),
+})
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua
index 43362f0..b8b5927 100644
--- a/lua/config/lazy.lua
+++ b/lua/config/lazy.lua
@@ -47,6 +47,16 @@ require("lazy").setup({
end,
},
{
+ "ray-x/lsp_signature.nvim",
+ event = "VeryLazy",
+ opts = {
+ doc_lines = 0,
+ },
+ config = function(_, opts)
+ require("lsp_signature").setup(opts)
+ end,
+ },
+ {
--snippets
"L3MON4D3/LuaSnip",
version = "v2.*",
@@ -65,6 +75,25 @@ require("lazy").setup({
},
{
+ "folke/which-key.nvim",
+ event = "VeryLazy",
+ opts = {
+ win = {
+ border = "rounded",
+ },
+ },
+ keys = {
+ {
+ "<leader>?",
+ function()
+ require("which-key").show({ global = false })
+ end,
+ desc = "Buffer Local Keymaps (which-key)",
+ },
+ },
+ },
+
+ {
"christoomey/vim-tmux-navigator",
cmd = {
"TmuxNavigateLeft",
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index d5645af..b913dac 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -1,62 +1,67 @@
-- [[ Keybinds ]]
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
+local cmp = require("cmp")
+local context = require("cmp.config.context")
+local diagnostic = vim.diagnostic
+local lbuf = vim.lsp.buf
local map = vim.keymap.set
-map("n", " la", vim.lsp.buf.code_action)
-map("n", "gd", vim.lsp.buf.definition)
-map("n", " r", vim.lsp.buf.rename)
-map("n", " li", vim.lsp.buf.implementation)
-map("n", " lh", vim.lsp.buf.signature_help)
-map("n", " lt", vim.lsp.buf.typehierarchy)
-map("n", " lr", vim.lsp.buf.references)
-map("n", " ls", vim.lsp.buf.document_symbol)
-map("n", " ld", vim.lsp.buf.type_definition)
-map("n", " lq", vim.diagnostic.setqflist)
-
--- [[ LSP Setups ]]
local lspconfig = require("lspconfig")
+local lspkind = require("lspkind")
+local builtin = require("telescope.builtin")
-lspconfig.gopls.setup({})
-lspconfig.clangd.setup({})
-lspconfig.emmet_ls.setup({})
+map("n", " lca", lbuf.code_action, { desc = "Code actions" })
+map("n", "gd", lbuf.definition, { desc = "Definition" })
+map("n", " lrn", lbuf.rename, { desc = "Rename" })
+map("n", " lim", builtin.lsp_implementations, { desc = "Implementation" })
+map("n", " lsh", lbuf.signature_help, { desc = "Signature help" })
+map("n", " lth", lbuf.typehierarchy, { desc = "Type hierarchy" })
+map("n", " llf", lbuf.references, { desc = "References" })
+map("n", " lds", lbuf.document_symbol, { desc = "List symbols" })
+map("n", " ltd", lbuf.type_definition, { desc = "Type definition" })
+-- map("n", " lls", vim.lsp.handlers["workspace/symbol"])
+map("n", " lq", diagnostic.setqflist, { desc = "Diagnostic quickfix" })
+map("n", " >>", diagnostic.goto_next, { desc = "Diagnostic next" })
+map("n", " <<", diagnostic.goto_prev, { desc = "Diagnostic prev" })
+map("n", " <,", function()
+ diagnostic.goto_next({ severity = diagnostic.ERROR })
+end, { desc = "Diagnostic next error" })
+map("n", " >.", function()
+ diagnostic.goto_prev({ severity = diagnostic.ERROR })
+end, { desc = "Diagnostic prev error" })
+map("n", " vf", diagnostic.open_float, { desc = "Diagnostics open floating window" })
+-- map("n", " ")
--- lua
--- with neovim support
-require("lspconfig").lua_ls.setup({
- on_init = function(client)
- local path = client.workspace_folders[1].name
- if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
- return
- end
+-- [[ LSP Setups ]]
- client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
- runtime = {
- -- Tell the language server which version of Lua you're using
- -- (most likely LuaJIT in the case of Neovim)
- version = "LuaJIT",
- },
- -- Make the server aware of Neovim runtime files
- workspace = {
- checkThirdParty = false,
- library = {
- vim.env.VIMRUNTIME,
- -- Depending on the usage, you might want to add additional paths here.
- -- "${3rd}/luv/library"
- -- "${3rd}/busted/library",
- },
- -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
- -- library = vim.api.nvim_get_runtime_file("", true)
- },
- })
- end,
+lspconfig.gopls.setup({
settings = {
- Lua = {},
+ gopls = {
+ hints = {
+ assignVariableTypes = true,
+ compositeLiteralFields = true,
+ compositeLiteralTypes = true,
+ constantValues = true,
+ functionTypeParameters = true,
+ parameterNames = true,
+ rangeVariableTypes = true,
+ },
+ },
+ },
+})
+lspconfig.clangd.setup({})
+lspconfig.emmet_ls.setup({})
+lspconfig.ts_ls.setup({})
+lspconfig.powershell_es.setup({
+ cmd = {
+ "pwsh",
+ "-NoLog",
+ "-NoProfile",
+ "-Command",
+ "/home/aluc/.local/share/nvim/mason/packages/powershell-editor-services/PowerShellEditorServices/Start-EditorServices.ps1",
},
})
-- [[ nvim cmp ]]
-require("cmp_nvim_lsp").default_capabilities()
-local cmp = require("cmp")
-local context = require("cmp.config.context")
-local lspkind = require("lspkind")
cmp.setup({
enabled = function()
if context.in_treesitter_capture("comment") == true or context.in_syntax_group("Comment") then
@@ -116,3 +121,41 @@ cmp.setup({
})
vim.api.nvim_set_hl(0, "CmpItemMenu", { italic = true })
+
+-- rounded border around floating windows
+local _border = "rounded"
+vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
+ border = _border,
+})
+vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
+ border = _border,
+})
+vim.diagnostic.config({
+ float = { border = _border },
+})
+-- lua
+-- with neovim support
+require("lspconfig").lua_ls.setup({
+ on_init = function(client)
+ local path = client.workspace_folders[1].name
+ if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
+ return
+ end
+
+ client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
+ runtime = {
+ version = "LuaJIT",
+ },
+ -- Make the server aware of Neovim runtime files
+ workspace = {
+ checkThirdParty = false,
+ library = {
+ vim.env.VIMRUNTIME,
+ },
+ },
+ })
+ end,
+ settings = {
+ Lua = {},
+ },
+})
diff --git a/lua/config/set.lua b/lua/config/set.lua
index 08c5d26..82fd73f 100644
--- a/lua/config/set.lua
+++ b/lua/config/set.lua
@@ -63,6 +63,7 @@ opt.showmatch = false
-- highlight line at cursor
opt.cursorline = true
opt.textwidth = 100
+opt.colorcolumn = "100"
-- status line
-- show ruler
@@ -99,18 +100,6 @@ end
opt.title = true
--- rounded border around floating windows
-local _border = "rounded"
-vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
- border = _border,
-})
-vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
- border = _border,
-})
-vim.diagnostic.config({
- float = { border = _border },
-})
-
-- Highlighting
vim.cmd("match Todo /\\(TODO\\|FIXME\\):/")