Update init.lua. Update claude settings
This commit is contained in:
parent
1220410938
commit
46c9bbe39c
2 changed files with 107 additions and 30 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"model": "opus",
|
"model": "sonnet",
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"Notification": [
|
"Notification": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ vim.call('plug#begin')
|
||||||
Plug 'nvim-tree/nvim-web-devicons'
|
Plug 'nvim-tree/nvim-web-devicons'
|
||||||
Plug 'nvim-tree/nvim-tree.lua'
|
Plug 'nvim-tree/nvim-tree.lua'
|
||||||
|
|
||||||
|
Plug 'ellisonleao/gruvbox.nvim'
|
||||||
|
|
||||||
Plug 'williamboman/mason.nvim'
|
Plug 'williamboman/mason.nvim'
|
||||||
Plug 'williamboman/mason-lspconfig.nvim'
|
Plug 'williamboman/mason-lspconfig.nvim'
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
|
|
@ -15,25 +17,66 @@ Plug 'hrsh7th/cmp-path'
|
||||||
Plug 'hrsh7th/cmp-cmdline'
|
Plug 'hrsh7th/cmp-cmdline'
|
||||||
Plug 'hrsh7th/nvim-cmp'
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
|
|
||||||
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
|
Plug 'nvim-telescope/telescope.nvim'
|
||||||
|
|
||||||
vim.call('plug#end')
|
vim.call('plug#end')
|
||||||
|
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
|
||||||
|
vim.opt.termguicolors = true
|
||||||
|
vim.o.background = "dark"
|
||||||
|
require("gruvbox").setup({
|
||||||
|
contrast = "hard",
|
||||||
|
})
|
||||||
|
vim.cmd("colorscheme gruvbox")
|
||||||
|
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
ensure_installed = {"ts_ls"}
|
ensure_installed = {"ts_ls", "gopls"}
|
||||||
})
|
})
|
||||||
require("nvim-tree").setup({
|
require("nvim-tree").setup({
|
||||||
|
view = {
|
||||||
|
number = false,
|
||||||
|
relativenumber = false,
|
||||||
|
},
|
||||||
|
renderer = {
|
||||||
|
indent_markers = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
icons = {
|
||||||
|
show = {
|
||||||
|
git = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
highlight_git = "name",
|
||||||
|
highlight_opened_files = "name",
|
||||||
|
},
|
||||||
filters = {
|
filters = {
|
||||||
dotfiles = false,
|
dotfiles = false,
|
||||||
},
|
},
|
||||||
git = {
|
git = {
|
||||||
ignore = false,
|
ignore = false,
|
||||||
}
|
},
|
||||||
|
actions = {
|
||||||
|
open_file = {
|
||||||
|
quit_on_open = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
require("lspconfig").ts_ls.setup {}
|
-- Global statuscolumn (line 190-ish) bakes in line numbers; nvim-tree doesn't
|
||||||
|
-- manage statuscolumn itself, so strip it locally for the tree buffer.
|
||||||
|
-- Must hook BufWinEnter (not FileType): nvim-tree sets 'filetype' on the
|
||||||
|
-- buffer before moving it into its own split, so a FileType autocmd fires
|
||||||
|
-- in the wrong window and opt_local misses the tree's actual window.
|
||||||
|
vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||||
|
pattern = "NvimTree_*",
|
||||||
|
callback = function()
|
||||||
|
vim.opt_local.statuscolumn = ""
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
vim.opt.swapfile = true
|
vim.opt.swapfile = true
|
||||||
|
|
@ -45,21 +88,13 @@ local cmp = require'cmp'
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
-- REQUIRED - you must specify a snippet engine
|
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
vim.snippet.expand(args.body) -- native neovim snippets (Neovim v0.10+)
|
||||||
-- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
|
|
||||||
|
|
||||||
-- For `mini.snippets` users:
|
|
||||||
-- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
|
|
||||||
-- insert({ body = args.body }) -- Insert at cursor
|
|
||||||
-- cmp.resubscribe({ "TextChangedI", "TextChangedP" })
|
|
||||||
-- require("cmp.config").set_onetime({ sources = {} })
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
-- completion = cmp.config.window.bordered(),
|
completion = cmp.config.window.bordered(),
|
||||||
-- documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
|
@ -70,10 +105,6 @@ cmp.setup({
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'vsnip' }, -- For vsnip users.
|
|
||||||
-- { name = 'luasnip' }, -- For luasnip users.
|
|
||||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
|
||||||
-- { name = 'snippy' }, -- For snippy users.
|
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
})
|
})
|
||||||
|
|
@ -115,25 +146,71 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
require('lspconfig')['ts_ls'].setup {
|
require('lspconfig')['ts_ls'].setup {
|
||||||
capabilities = capabilities
|
capabilities = capabilities
|
||||||
}
|
}
|
||||||
|
require('lspconfig')['gopls'].setup {
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Format Go files on save using the attached LSP server (gopls).
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
pattern = "*.go",
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Close any open floating windows (e.g. the hover/signature-help popup).
|
||||||
|
local function close_floating_windows()
|
||||||
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
|
if vim.api.nvim_win_get_config(win).relative ~= "" then
|
||||||
|
vim.api.nvim_win_close(win, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', '<Esc>', close_floating_windows, { noremap = true, silent = true })
|
||||||
|
|
||||||
|
-- Give all floating windows (hover, signature-help, diagnostics, etc.) a rounded border.
|
||||||
|
vim.o.winborder = "rounded"
|
||||||
|
|
||||||
|
-- Match floating windows' background to the main editor background.
|
||||||
|
vim.api.nvim_set_hl(0, "NormalFloat", { link = "Normal" })
|
||||||
|
vim.api.nvim_set_hl(0, "FloatBorder", { link = "Normal" })
|
||||||
|
|
||||||
|
-- LSP keymaps, set up per-buffer whenever a language server attaches.
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(args)
|
||||||
|
local opts = { noremap = true, silent = true, buffer = args.buf }
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- set space as leader keymap
|
-- set space as leader keymap
|
||||||
vim.keymap.set('n', ' ', '<Nop>', {noremap = true, silent = true})
|
vim.keymap.set('n', ' ', '<Nop>', {noremap = true, silent = true})
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
|
|
||||||
|
-- Diagnostic keymaps (not tied to LspAttach; work globally)
|
||||||
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { noremap = true, silent = true })
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>x', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
|
vim.keymap.set('n', '<leader>x', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
|
||||||
vim.keymap.set('n', '<leader>n', ':bnext<CR>', {noremap = true, silent = true})
|
vim.keymap.set('n', '<leader>n', ':bnext<CR>', {noremap = true, silent = true})
|
||||||
vim.keymap.set('n', '<leader>p', ':bprevious<CR>', {noremap = true, silent = true})
|
vim.keymap.set('n', '<leader>p', ':bprevious<CR>', {noremap = true, silent = true})
|
||||||
vim.keymap.set('n', '<leader>d', ':bdelete<CR>', {noremap = true, silent = true})
|
vim.keymap.set('n', '<leader>d', ':bdelete<CR>', {noremap = true, silent = true})
|
||||||
|
|
||||||
vim.opt.statuscolumn = "%s %l %r "
|
require('telescope').setup()
|
||||||
|
local telescopeBuiltin = require('telescope.builtin')
|
||||||
|
vim.keymap.set('n', '<leader>ff', telescopeBuiltin.find_files, {noremap = true, silent = true})
|
||||||
|
vim.keymap.set('n', '<leader>fg', telescopeBuiltin.live_grep, {noremap = true, silent = true})
|
||||||
|
vim.keymap.set('n', '<leader>fb', telescopeBuiltin.buffers, {noremap = true, silent = true})
|
||||||
|
vim.keymap.set('n', '<leader>fh', telescopeBuiltin.help_tags, {noremap = true, silent = true})
|
||||||
|
|
||||||
|
vim.opt.statuscolumn = "%s %3{v:lnum} %-3{v:relnum} "
|
||||||
vim.o.rnu=true
|
vim.o.rnu=true
|
||||||
|
|
||||||
local treeApi = require("nvim-tree.api")
|
|
||||||
|
|
||||||
-- Close the tree when a new buffer is opened
|
|
||||||
vim.api.nvim_create_autocmd("BufEnter", {
|
|
||||||
callback = function()
|
|
||||||
if (vim.fn.bufname() == "NvimTree_1") then return end
|
|
||||||
treeApi.tree.close()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue