Skip to content

Commit

Permalink
icmp and snip rice
Browse files Browse the repository at this point in the history
  • Loading branch information
iofq committed Aug 8, 2024
1 parent 62b7e83 commit 2a6ff7e
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 27 deletions.
92 changes: 90 additions & 2 deletions config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ vim.keymap.set("n", "<leader>fg", telescope.git_files, {noremap = true, silent =
vim.keymap.set("n", "<leader>fc", telescope.command_history, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fa", telescope.live_grep, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>f8", telescope.grep_string, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fs", telescope.treesitter, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fq", telescope.quickfix, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fq", telescope.quickfix, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>f<BS>", telescope.resume, {noremap = true, silent = true})

local telescope = require("telescope")
Expand Down Expand Up @@ -113,12 +116,14 @@ require("nvim-treesitter.configs").setup {

-- Setup language servers.
local lspconfig = require('lspconfig')
local capabilities = require('cmp_nvim_lsp').default_capabilities()
lspconfig.gopls.setup { on_attach = function(_, bufnr)
capabilities = capabilities
vim.api.nvim_command("au BufWritePre <buffer> lua vim.lsp.buf.format { async = false }")
end
}
lspconfig.pyright.setup {}
lspconfig.nil_ls.setup {}
lspconfig.pyright.setup { capabilities = capabilities }
lspconfig.nil_ls.setup { capabilities = capabilities }

-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
Expand Down Expand Up @@ -149,6 +154,8 @@ vim.api.nvim_create_autocmd('LspAttach', {
vim.keymap.set("n", "<leader>dr", "<cmd>Telescope lsp_references<cr>", { buffer = bufnr })
vim.keymap.set("n", "<leader>dt", "<cmd>Telescope lsp_type_definitions<cr>", { buffer = bufnr })
vim.keymap.set("n", "<leader>ds", "<cmd>Telescope lsp_document_symbols<cr>", { buffer = bufnr })
vim.keymap.set('n', '<leader>dl', vim.lsp.codelens.run)
vim.keymap.set('n', '<leader>dg', vim.diagnostic.setqflist)
vim.keymap.set('n', '<space>df', function()
vim.lsp.buf.format { async = true }
end, opts)
Expand Down Expand Up @@ -239,6 +246,87 @@ require("rose-pine").setup({
})
vim.cmd.colorscheme "rose-pine-main"

--------------------
-- Neogen
--------------------
require("neogen").setup{}
vim.keymap.set("n","<leader>nd", "<cmd>Neogen<CR>", {noremap = true, silent = true})

--------------------
---Completion
--------------------
local cmp = require'cmp'

cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-j>'] = cmp.mapping.scroll_docs(-4),
['<C-k>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['q'] = cmp.mapping.abort(),
['<C-Space>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
})
})

cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})

cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
matching = { disallow_symbol_nonprefix_matching = false }
})

--------------------
-- Luasnip
--------------------
local ls = require("luasnip")
ls.config.set_config {
history = true,
updateevents = "TextChanged, TextChangedI",
}
require("luasnip.loaders.from_vscode").lazy_load()

vim.keymap.set({"i", "s"}, "<C-K>", function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end, {silent = true})

vim.keymap.set({"i", "s"}, "<C-J>", function()
if ls.jumpable(-1) then
ls.jump(-1)
end
end, {silent = true})

vim.keymap.set({"i", "s"}, "<C-L>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end, {silent = true})

--------------------
-- Snippets
--------------------
require("snippets")
--------------------
-- include our config last to override
--------------------
Expand Down
27 changes: 14 additions & 13 deletions config/lua/mini-conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ require('mini.pairs').setup(
mappings = {
['['] = { action = 'open', pair = '[]', neigh_pattern = '[^\\].' },
['{'] = { action = 'open', pair = '{}', neigh_pattern = '[^\\].' },

[']'] = { action = 'close', pair = '[]', neigh_pattern = '[^\\].' },
['}'] = { action = 'close', pair = '{}', neigh_pattern = '[^\\].' },
['"'] = { },
['\''] = { },
},
}
)
Expand All @@ -75,15 +76,15 @@ indent.setup({
indent.gen_animation.none()

-- <C-Space>
require('mini.completion').setup({
delay = {completion = 10^7},
window = {
info = { height = 25, width = 80, border = 'single' },
signature = { height = 25, width = 80, border = 'single' },
},
lsp_completion = {
source_func = 'completefunc',
auto_setup = true,
},
fallback_action = "<C-x><C-n>"
})
-- require('mini.completion').setup({
-- delay = {completion = 10^7},
-- window = {
-- info = { height = 25, width = 80, border = 'single' },
-- signature = { height = 25, width = 80, border = 'single' },
-- },
-- lsp_completion = {
-- source_func = 'completefunc',
-- auto_setup = true,
-- },
-- fallback_action = "<C-x><C-n>"
-- })
21 changes: 9 additions & 12 deletions config/lua/nvim-conf.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-- vim settings ++ mini.nvim.basics
----------------------------------------
vim.opt.backspace = "indent,eol,start"
vim.opt.clipboard = "unnamedplus" -- use system clipboard
vim.opt.completeopt = "menuone"
vim.opt.expandtab = true -- insert tabs as spaces
vim.opt.inccommand = "split" -- incremental live completion
Expand All @@ -27,20 +26,18 @@ vim.g.indent_blankline_use_treesitter = true

-- no highlight floats
vim.cmd([[ hi NormalFloat ctermbg=none ]])

-- mappings
----------------------------------------

local remap = function(type, key, value)
vim.api.nvim_set_keymap(type,key,value,{noremap = true, silent = true});
end

remap("i", "wq", "<esc>l")
remap("v", "wq", "<esc>l")
remap("n","gr", "gT")
remap("n","n", "nzz")
remap("n", "N", "Nzz")
remap("n","<CR>", "m0i<cr><Esc>`0")
vim.keymap.set("n","gr", "gT", {noremap = true, silent = true})
vim.keymap.set("n","n", "nzz", {noremap = true, silent = true})
vim.keymap.set("n", "N", "Nzz", {noremap = true, silent = true})
vim.keymap.set("n","<CR>", "m0i<cr><Esc>`0", {noremap = true, silent = true})
vim.keymap.set({'v', 'i'}, 'wq', '<esc>l', {noremap = true, silent = true})
vim.keymap.set({'n', 'v', 'i'}, 'qwq', '<esc>l<cmd>wqa<CR>', {noremap = true, silent = true})
vim.keymap.set({'n', 'v'}, '<leader>yy', '"+y', {noremap = true, silent = true})
vim.keymap.set({'n', 'v'}, '<leader>yp', '"+p', {noremap = true, silent = true})
vim.keymap.set({'n', 'v'}, '<leader>yd', '"+d', {noremap = true, silent = true})

-- Switch tab length on the fly
vim.keymap.set("n", "\\t", function()
Expand Down
3 changes: 3 additions & 0 deletions config/lua/snippets.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ls.add_snippets("go", {
s("ie", fmta("if err != nil {\n\treturn <err>\n}", { err = i(1, "err") })),
})
10 changes: 10 additions & 0 deletions plugins.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{pkgs, ...}:
{
base = with pkgs.vimPlugins; [
cmp-buffer
cmp-cmdline
cmp-nvim-lsp
cmp-path
cmp-treesitter
cmp_luasnip
diffview-nvim
friendly-snippets
gitsigns-nvim
luasnip
mini-nvim
neogen
neogit
nvim-cmp
nvim-lspconfig
nvim-treesitter-textobjects
(nvim-treesitter.withPlugins(p: with p; [
Expand Down

0 comments on commit 2a6ff7e

Please sign in to comment.