Added autocomplete + terminal and lazygit floating term
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
-- REQUIRED PLUGINS (via your plugin manager, e.g., Packer/Lazy):
|
||||
-- 1. 'hrsh7th/nvim-cmp' (The completion engine)
|
||||
-- 2. 'hrsh7th/cmp-nvim-lsp' (Bridge between LSP and cmp)
|
||||
-- 3. 'neovim/nvim-lspconfig' (Configs for ZLS)
|
||||
-- 4. 'L3MON4D3/LuaSnip' (Snippet engine, required by cmp)
|
||||
|
||||
local cmp = require('cmp')
|
||||
local lspconfig = require('lspconfig')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
-- 1. SETUP THE COMPLETION ENGINE
|
||||
cmp.setup({
|
||||
-- Snippet expansion is required for arguments to populate correctly
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
-- Window styling for the suggestion box and documentation float
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
-- Key mappings
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(), -- Force trigger completion
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept suggestion
|
||||
}),
|
||||
|
||||
-- Sources: 'nvim_lsp' is what provides the intelligent 'self' data
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
|
||||
-- formatting: This adds the "Method", "Field", "Text" icons
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
},
|
||||
})
|
||||
|
||||
-- 2. SETUP ZIG LANGUAGE SERVER (ZLS)
|
||||
-- This captures the capabilities of nvim-cmp to send to ZLS
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
lspconfig.zls.setup({
|
||||
capabilities = capabilities,
|
||||
|
||||
-- ZLS Specific Settings to ensure you get arguments and details
|
||||
settings = {
|
||||
zls = {
|
||||
enable_snippets = true, -- Auto-fill arguments
|
||||
enable_argument_placeholders = true, -- Placeholders like (a: i32, b: bool)
|
||||
highlight_global_var_declarations = true,
|
||||
operator_completions = true,
|
||||
include_at_in_builtins = true, -- Suggest @import, @cImport
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -1,7 +1,29 @@
|
||||
local wk = require("which-key")
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
local Terminal = require('toggleterm.terminal').Terminal
|
||||
local lazygit = Terminal:new({
|
||||
cmd = "lazygit",
|
||||
dir = "git_dir",
|
||||
direction = "float",
|
||||
float_opts = {
|
||||
border = "double",
|
||||
},
|
||||
-- function to run on opening the terminal
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
|
||||
end,
|
||||
})
|
||||
|
||||
function _lazygit_toggle()
|
||||
lazygit:toggle()
|
||||
end
|
||||
|
||||
wk.add({
|
||||
{ "<leader>t", "<cmd>ToggleTerm<cr>", desc = "Toggle Floating Terminal"},
|
||||
{"<leader>g", "<cmd>lua _lazygit_toggle()<CR>", desc = "Toggle LazyGit"},
|
||||
|
||||
-- Essentials
|
||||
{ "<leader>w", "<cmd>w<cr>", desc = "Save File" },
|
||||
{ "<leader>q", "<cmd>q<cr>", desc = "Quit" },
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
local configs = require 'nvim_lsp/configs'
|
||||
local util = require 'nvim_lsp/util'
|
||||
|
||||
configs.zls = {
|
||||
default_config = {
|
||||
cmd = {"/usr/local/bin/zls"};
|
||||
filetypes = {"zig"};
|
||||
root_dir = util.root_pattern("build.zig", ".git");
|
||||
};
|
||||
docs = {
|
||||
description = [[ ]];
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("build.zig", ".git")]];
|
||||
};
|
||||
};
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
||||
Reference in New Issue
Block a user