Skip to content

Commit

Permalink
nvim: update plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
keidarcy committed Oct 6, 2024
1 parent 73b21fe commit 74647bb
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 108 deletions.
3 changes: 2 additions & 1 deletion nvim/.config/nvim/lua/keidarcy/packer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ local function setup()
-- treesitter
use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
use("nvim-treesitter/playground")
use("p00f/nvim-ts-rainbow")
use("HiPhish/nvim-ts-rainbow2")

-- git
use("tpope/vim-fugitive")
Expand Down Expand Up @@ -81,6 +81,7 @@ local function setup()
{ "L3MON4D3/LuaSnip" },
{ "rafamadriz/friendly-snippets" },
},
branch = "v4.x",
})
use("github/copilot.vim")
use("folke/zen-mode.nvim")
Expand Down
15 changes: 6 additions & 9 deletions nvim/.config/nvim/lua/plugins/gitsigns.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require("gitsigns").setup({
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
topdelete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
changedelete = { hl = "GitSignsChange", text = "~", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
untracked = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
add = { text = "+" },
change = { text = "~" },
delete = { text = "󰧧" },
topdelete = { text = "󰆴" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
Expand Down Expand Up @@ -36,9 +36,6 @@ require("gitsigns").setup({
row = 0,
col = 1,
},
yadm = {
enable = false,
},
})

vim.cmd([[highlight! link SignColumn Normal]])
277 changes: 192 additions & 85 deletions nvim/.config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,101 +1,208 @@
local navic = require("nvim-navic")
local lsp = require("lsp-zero")
local lsp_zero = require("lsp-zero")

lsp.preset("recommended")
local lsp_attach = function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({ buffer = bufnr })
end

lsp.ensure_installed({
"tsserver",
"eslint",
"lua_ls",
"rust_analyzer",
"gopls",
lsp_zero.extend_lspconfig({
capabilities = require("cmp_nvim_lsp").default_capabilities(),
lsp_attach = lsp_attach,
float_border = "rounded",
sign_text = {
error = "",
warn = "",
hint = "",
info = "",
},
})

-- Fix Undefined global 'vim'
lsp.configure("lua_ls", {
settings = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = {
"tsserver",
"eslint",
"lua_ls",
"rust_analyzer",
"gopls",
},
handlers = {
function(server_name)
require("lspconfig")[server_name].setup({})
end,
lua_ls = function()
require("lspconfig").lua_ls.setup({
on_init = function(client)
lsp_zero.nvim_lua_settings(client, {})
end,
})
end,
},
})

local cmp = require("cmp")
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
-- ["<CR>"] = cmp.mapping.complete(),
vim.keymap.set("n", "gl", "<cmd>lua vim.diagnostic.open_float()<cr>")

vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
float = {
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
})

-- disable completion with tab
-- this helps with copilot setup
cmp_mappings["<Tab>"] = nil
cmp_mappings["<S-Tab>"] = nil
-- disable enter
-- cmp_mappings['<CR>'] = nil
local cmp = require("cmp")
local cmp_action = lsp_zero.cmp_action()
local cmp_format = lsp_zero.cmp_format()

lsp.setup_nvim_cmp({
mapping = cmp_mappings,
})
require("luasnip.loaders.from_vscode").lazy_load()

lsp.set_preferences({
suggest_lsp_servers = false,
set_lsp_keymaps = false,
configure_diagnostics = true,
cmp_capabilities = true,
manage_nvim_cmp = true,
call_servers = "local",
sign_icons = {
error = "",
warn = "",
hint = "",
info = "",
vim.opt.completeopt = { "menu", "menuone", "noselect" }

cmp.setup({
formatting = cmp_format,
preselect = "item",
completion = {
completeopt = "menu,menuone,noinsert",
},
})
window = {
documentation = cmp.config.window.bordered(),
},
sources = {
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "buffer", keyword_length = 3 },
{ name = "luasnip", keyword_length = 2 },
},
mapping = cmp.mapping.preset.insert({
-- confirm completion item
["<CR>"] = cmp.mapping.confirm({ select = false }),

lsp.on_attach(function(client, bufnr)
local map = function(mode, lhs, rhs)
local opts = { remap = false, buffer = bufnr }
vim.keymap.set(mode, lhs, rhs, opts)
end

if client.server_capabilities.documentSymbolProvider then
navic.attach(client, bufnr)
end

-- how to disable eslint
-- if client.name == "eslint" then
-- vim.cmd.LspStop('eslint')
-- return
-- end

-- LSP actions
map("n", "gh", vim.lsp.buf.hover)
map("n", "gd", vim.lsp.buf.definition)
map("n", "gD", vim.lsp.buf.declaration)
map("n", "gi", vim.lsp.buf.implementation)
map("n", "go", vim.lsp.buf.type_definition)
map("n", "gr", vim.lsp.buf.references)
map("n", "<C-k>", vim.lsp.buf.signature_help)
map("n", "<F2>", vim.lsp.buf.rename)
map("n", "<F4>", vim.lsp.buf.code_action)
-- map('x', '<F4>', vim.lsp.buf.range_code_action)
map("x", "<F4>", "<cmd>lua vim.lsp.buf.range_code_action()<cr>")

-- Diagnostics
map("n", "gl", vim.diagnostic.open_float)
map("n", "[d", vim.diagnostic.goto_prev)
map("n", "]d", vim.diagnostic.goto_next)
-- map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
end)

lsp.setup()
-- toggle completion menu
["<C-e>"] = cmp_action.toggle_completion(),

vim.diagnostic.config({
virtual_text = true,
-- tab complete
["<Tab>"] = cmp_action.tab_complete(),
["<S-Tab>"] = cmp.mapping.select_prev_item(),

-- navigate between snippet placeholder
["<C-d>"] = cmp_action.luasnip_jump_forward(),
["<C-b>"] = cmp_action.luasnip_jump_backward(),

-- scroll documentation window
["<C-f>"] = cmp.mapping.scroll_docs(5),
["<C-u>"] = cmp.mapping.scroll_docs(-5),
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
})

vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
-- local navic = require("nvim-navic")
-- local lsp = require("lsp-zero")

-- lsp.preset("recommended")

-- lsp.ensure_installed({
-- "tsserver",
-- "eslint",
-- "lua_ls",
-- "rust_analyzer",
-- "gopls",
-- })

-- -- Fix Undefined global 'vim'
-- lsp.configure("lua_ls", {
-- settings = {
-- Lua = {
-- workspace = { checkThirdParty = false },
-- telemetry = { enable = false },
-- },
-- },
-- })

-- local cmp = require("cmp")
-- local cmp_select = { behavior = cmp.SelectBehavior.Select }
-- local cmp_mappings = lsp.defaults.cmp_mappings({
-- ["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
-- ["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
-- ["<C-y>"] = cmp.mapping.confirm({ select = true }),
-- -- ["<CR>"] = cmp.mapping.complete(),
-- })

-- -- disable completion with tab
-- -- this helps with copilot setup
-- cmp_mappings["<Tab>"] = nil
-- cmp_mappings["<S-Tab>"] = nil
-- -- disable enter
-- -- cmp_mappings['<CR>'] = nil

-- lsp.setup_nvim_cmp({
-- mapping = cmp_mappings,
-- })

-- lsp.set_preferences({
-- suggest_lsp_servers = false,
-- set_lsp_keymaps = false,
-- configure_diagnostics = true,
-- cmp_capabilities = true,
-- manage_nvim_cmp = true,
-- call_servers = "local",
-- sign_icons = {
-- error = "✘",
-- warn = "▲",
-- hint = "⚑",
-- info = "",
-- },
-- })

-- lsp.on_attach(function(client, bufnr)
-- local map = function(mode, lhs, rhs)
-- local opts = { remap = false, buffer = bufnr }
-- vim.keymap.set(mode, lhs, rhs, opts)
-- end

-- if client.server_capabilities.documentSymbolProvider then
-- navic.attach(client, bufnr)
-- end

-- -- how to disable eslint
-- -- if client.name == "eslint" then
-- -- vim.cmd.LspStop('eslint')
-- -- return
-- -- end

-- -- LSP actions
-- map("n", "gh", vim.lsp.buf.hover)
-- map("n", "gd", vim.lsp.buf.definition)
-- map("n", "gD", vim.lsp.buf.declaration)
-- map("n", "gi", vim.lsp.buf.implementation)
-- map("n", "go", vim.lsp.buf.type_definition)
-- map("n", "gr", vim.lsp.buf.references)
-- map("n", "<C-k>", vim.lsp.buf.signature_help)
-- map("n", "<F2>", vim.lsp.buf.rename)
-- map("n", "<F4>", vim.lsp.buf.code_action)
-- -- map('x', '<F4>', vim.lsp.buf.range_code_action)
-- map("x", "<F4>", "<cmd>lua vim.lsp.buf.range_code_action()<cr>")

-- -- Diagnostics
-- map("n", "gl", vim.diagnostic.open_float)
-- map("n", "[d", vim.diagnostic.goto_prev)
-- map("n", "]d", vim.diagnostic.goto_next)
-- -- map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
-- end)

-- lsp.setup()

-- vim.diagnostic.config({
-- virtual_text = true,
-- })

-- vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
20 changes: 10 additions & 10 deletions nvim/.config/nvim/lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local rainbow = { "#CC8888", "#CCCC88", "#88CC88", "#88CCCC", "#8888CC", "#CC88CC" }

require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all"
ensure_installed = { "help", "javascript", "typescript", "c", "lua", "rust", "go" },
Expand All @@ -23,13 +21,15 @@ require("nvim-treesitter.configs").setup({
},
rainbow = {
enable = true,
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
colors = rainbow,
termcolors = rainbow,
-- list of languages you want to disable the plugin for
-- disable = { "jsx", "cpp" },
-- Which query to use for finding delimiters
query = "rainbow-parens",
-- Highlight the entire buffer all at once
strategy = require("ts-rainbow").strategy.global,
},
})
for i, c in ipairs(rainbow) do -- p00f/rainbow#81
vim.cmd(("hi rainbowcol%d guifg=%s"):format(i, c))
end
-- This part is no longer necessary with nvim-ts-rainbow2
-- for i, c in ipairs(rainbow) do -- p00f/rainbow#81
-- vim.cmd(("hi rainbowcol%d guifg=%s"):format(i, c))
-- end
4 changes: 3 additions & 1 deletion nvim/.config/nvim/lua/plugins/which-key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ if not status_ok then
return
end

require("which-key.health").check()

-- local opts = {
-- mode = "n", -- NORMAL mode
-- -- prefix: use "<leader>f" for example for mapping everything related to finding files
Expand Down Expand Up @@ -35,4 +37,4 @@ end
local mappings = {}
local opts = {}

wk.register(mappings, opts)
wk.add(mappings, opts)
2 changes: 1 addition & 1 deletion work-dotfiles
2 changes: 1 addition & 1 deletion zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fi
source <(kubectl completion zsh)

# https://zsh-abbr.olets.dev/commands.html#import-aliases
abbr -q import-aliases
# abbr -q import-aliases

#region custom
# custom scripts
Expand Down

0 comments on commit 74647bb

Please sign in to comment.