-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = ","
vim.g.maplocalleader = "\\"
-- Settings from .vimrc
vim.opt.compatible = false
vim.opt.wrap = false
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.backspace = "indent,eol,start"
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.wildignore = "*/node_modules/*,**/node_modules/**,yarn.lock"
vim.opt.number = true
vim.opt.laststatus = 2
vim.opt.statusline = " %f %m %r %=%v:%l/%L "
-- Enable syntax highlighting
vim.cmd("syntax on")
-- Enable filetype detection, plugins, and indentation
vim.cmd("filetype plugin indent on")
-- Key mappings from .vimrc
vim.keymap.set('n', '<leader>u', 'mQviwU`Q', { desc = 'Upper case word' })
vim.keymap.set('n', '<leader>l', 'mQviwu`Q', { desc = 'Lower case word' })
vim.keymap.set('n', '<leader>U', 'mQgewvU`Q', { desc = 'Upper case first char' })
vim.keymap.set('n', '<leader>L', 'mQgewvu`Q', { desc = 'Lower case first char' })
-- Command aliases
vim.cmd("cnoreabbrev Wq wq")
-- Restore cursor position
vim.api.nvim_create_autocmd("BufReadPost", {
pattern = "*",
callback = function()
if vim.fn.line("'\"") > 0 and vim.fn.line("'\"") <= vim.fn.line("$") then
vim.fn.execute("normal! g`\"")
end
end,
})
-- Setup lazy.nvim
require("lazy").setup({
spec = {
------ copied from https://gist.github.com/mekeor/2eb3ced1a666c8d6a20c03a70ad36483 ------
---- autocompletion
{
-- package recommended by https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion/217feffc675a17d8ab95259ed9d4c6d62e1cd2e1#autocompletion-not-built-in-vs-completion-built-in
'hrsh7th/nvim-cmp',
config = function(cmp)
local cmp = require('cmp')
cmp.setup({
completion = { completeopt = 'menu,menuone,noinsert' },
-- if desired, choose another keymap-preset:
mapping = cmp.mapping.preset.insert(),
-- optionally, add more completion-sources:
sources = cmp.config.sources({{ name = 'nvim_lsp' }}),
})
end,
},
---- code formatting
{
'mhartington/formatter.nvim',
config = function()
local formatter_prettier = { require('formatter.defaults.prettier') }
require("formatter").setup({
filetype = {
javascript = formatter_prettier,
javascriptreact = formatter_prettier,
typescript = formatter_prettier,
typescriptreact = formatter_prettier,
}
})
-- automatically format buffer before writing to disk:
vim.api.nvim_create_augroup('BufWritePreFormatter', {})
vim.api.nvim_create_autocmd('BufWritePre', {
command = 'FormatWrite',
group = 'BufWritePreFormatter',
pattern = { '*.js', '*.jsx', '*.ts', '*.tsx' },
})
end,
ft = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' },
},
---- language server protocol (lsp)
{
-- use official lspconfig package (and enable completion):
'neovim/nvim-lspconfig', dependencies = { 'hrsh7th/cmp-nvim-lsp' },
config = function()
local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
local lsp_on_attach = function(client, bufnr)
local bufopts = { noremap=true, silent=true, buffer=bufnr }
-- following keymap is based on both lspconfig and lsp-zero.nvim:
-- - https://github.com/neovim/nvim-lspconfig/blob/fd8f18fe819f1049d00de74817523f4823ba259a/README.md?plain=1#L79-L93
-- - https://github.com/VonHeikemen/lsp-zero.nvim/blob/18a5887631187f3f7c408ce545fd12b8aeceba06/lua/lsp-zero/server.lua#L285-L298
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help , bufopts)
vim.keymap.set('n', 'K' , vim.lsp.buf.hover , bufopts)
vim.keymap.set('n', 'gD' , vim.lsp.buf.declaration , bufopts)
vim.keymap.set('n', 'gd' , vim.lsp.buf.definition , bufopts)
vim.keymap.set('n', 'gi' , vim.lsp.buf.implementation , bufopts)
vim.keymap.set('n', 'go' , vim.lsp.buf.type_definition , bufopts)
vim.keymap.set('n', 'gr' , vim.lsp.buf.references , bufopts)
--m.keymap.set('n', TODO , vim.lsp.buf.code_action , bufopts) -- lspconfig: <space>ca; lsp-zero: <F4>
--m.keymap.set('n', TODO , function() vim.lsp.buf.format { async = true } end, bufopts) -- lspconfig: <space>f
--m.keymap.set('n', TODO , vim.lsp.buf.rename , bufopts) -- lspconfig: <space>rn; lsp-zero: <F2>
end
local lspconfig = require('lspconfig')
-- enable both language-servers for both eslint and typescript:
for _, server in pairs({ 'eslint', 'tsserver' }) do
lspconfig[server].setup({
capabilities = lsp_capabilities,
on_attach = lsp_on_attach,
})
end
end,
ft = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' },
},
---- file navigation and more
{ 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' },
cmd = "Telescope",
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
end
},
---- tree-sitter
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function()
require('nvim-treesitter.configs').setup({
-- for syntax-highlight, instead of regular expressions, use tree-sitter:
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
})
end,
},
------ end of copy ------
{ 'nmac427/guess-indent.nvim' },
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons", -- optional, but recommended
},
lazy = false, -- neo-tree will lazily load itself
config = function()
vim.keymap.set("n", "<leader>n", "<Cmd>Neotree toggle<CR>")
end
},
{
"greggh/claude-code.nvim",
dependencies = {
"nvim-lua/plenary.nvim", -- Required for git operations
},
config = function()
require("claude-code").setup()
vim.keymap.set('n', '<leader>cc', '<cmd>ClaudeCode<CR>', { desc = 'Toggle Claude Code' })
end
},
-- add your plugins here
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})Metadata
Metadata
Assignees
Labels
No labels