Fully working python and R plugins

This commit is contained in:
hollorol 2024-07-30 20:11:20 +02:00
parent 030c0482c8
commit c795a01c10
7 changed files with 227 additions and 18 deletions

View File

@ -2,3 +2,4 @@ require("config.options")
require("config.keymaps")
require("config.lazy")
require("custom.functions")
-- require("custom.chatgpt")

View File

@ -1,7 +1,6 @@
return {
{'tpope/vim-fugitive'},
{'gorkunov/smartpairs.vim'},
{'SirVer/ultisnips'},
{'tpope/vim-surround'},
{'mattn/emmet-vim',
ft = { 'html', 'css', 'javascript', 'typescript', 'vue' },

View File

@ -0,0 +1,63 @@
return {
'Vigemus/iron.nvim',
config = function ()
local iron = require("iron.core")
iron.setup {
config = {
-- Whether a repl should be discarded or not
scratch_repl = true,
-- Your repl definitions come here
repl_definition = {
sh = {
-- Can be a table or a function that
-- returns a table (see below)
command = {"bash"}
},
python = {
command = { "ipython3", "--no-autoindent" }, -- or { "ipython", "--no-autoindent" }
format = require("iron.fts.common").bracketed_paste_python
}
},
-- How the repl window will be displayed
-- See below for more information
repl_open_cmd = require('iron.view').split.below(80),
},
-- Iron doesn't set keymaps by default anymore.
-- You can set them here or manually add keymaps to the functions in iron.core
keymaps = {
send_motion = "<space>sc",
visual_send = "<space>sc",
send_file = "<space>sf",
send_line = "<space>sl",
send_paragraph = "<space>sp",
send_until_cursor = "<space>su",
send_mark = "<space>sm",
mark_motion = "<space>mc",
mark_visual = "<space>mc",
remove_mark = "<space>md",
cr = "<space>s<cr>",
interrupt = "<space>s<space>",
exit = "<space>sq",
clear = "<space>cl",
},
-- If the highlight is on, you can change how it looks
-- For the available options, check nvim_set_hl
highlight = {
italic = true
},
ignore_blank_lines = true, -- ignore blank lines when sending visual select lines
}
-- iron also has a list of commands, see :h iron-commands for all available commands
vim.keymap.set('n', '<space>rs', '<cmd>IronRepl<cr>')
vim.keymap.set('n', '<space>rr', '<cmd>IronRestart<cr>')
vim.keymap.set('n', '<space>rf', '<cmd>IronFocus<cr>')
vim.keymap.set('n', '<space>rh', '<cmd>IronHide<cr>')
end
}

View File

@ -0,0 +1,150 @@
return {
-- Mason for managing external tools (LSP servers, linters, etc.)
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end
},
-- Mason LSP config to bridge Mason and nvim-lspconfig
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup {
ensure_installed = {"pyright"}
}
end
},
-- nvim-lspconfig for configuring LSP servers
{
"neovim/nvim-lspconfig",
config = function()
local lspconfig = require("lspconfig")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Setup LSP server (Pyright for Python)
lspconfig.pyright.setup {
capabilities = capabilities,
on_attach = function(client, bufnr)
local buf_set_keymap = vim.api.nvim_buf_set_keymap
local buf_set_option = vim.api.nvim_buf_set_option
buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Key mappings for LSP
local opts = { noremap = true, silent = true }
buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
-- Scroll hover documentation
buf_set_keymap(bufnr, 'n', '<C-f>', '<cmd>lua vim.lsp.util.scroll_popup(1)<CR>', opts)
buf_set_keymap(bufnr, 'n', '<C-b>', '<cmd>lua vim.lsp.util.scroll_popup(-1)<CR>', opts)
end,
}
end
},
-- nvim-cmp for autocompletion
{
"hrsh7th/nvim-cmp",
dependencies = {
"SirVer/ultisnips",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"quangnguyen30192/cmp-nvim-ultisnips",
-- "nvim-treesitter/nvim-treesitter", -- Ensure this for better syntax highlighting
"onsails/lspkind-nvim",
"hrsh7th/cmp-nvim-lsp-signature-help",
"R-nvim/cmp-r"
},
config = function()
local cmp = require'cmp'
local lspkind = require('lspkind')
cmp.setup({
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-R>=UltiSnips#ExpandSnippet()<CR>", true, true, true), "")
elseif vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-R>=UltiSnips#JumpForwards()<CR>", true, true, true), "")
else
fallback()
end
end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-R>=UltiSnips#JumpBackwards()<CR>", true, true, true), "")
else
fallback()
end
end, { "i", "s" }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'nvim_lsp_signature_help' },
{ name = 'ultisnips' },
{ name = "cmp_r" }
}, {
{ name = 'buffer' },
}),
formatting = {
format = lspkind.cmp_format({ with_text = true, maxwidth = 50 })
}
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline('?', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
require("cmp_r").setup({ })
end
}
}

View File

@ -2,22 +2,5 @@ return {
{
"R-nvim/R.nvim",
lazy = false
},
{
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function ()
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline", "r", "rnoweb", "yaml" },
})
end
},
"R-nvim/cmp-r",
{
"hrsh7th/nvim-cmp",
config = function()
require("cmp").setup({ sources = {{ name = "cmp_r" }}})
require("cmp_r").setup({ })
end,
}
}

View File

@ -0,0 +1,4 @@
return {
}

View File

@ -0,0 +1,9 @@
return{
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function ()
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline", "r", "rnoweb", "yaml", "python"},
})
end
}