Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("config.lazy")
- require("config.vim-tree")
- local lspconfig = require('lspconfig')
- local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
- lspconfig.lua_ls.setup{
- settings = {
- Lua = {
- runtime = {
- version = 'LuaJIT',
- },
- workspace = { checkThirdParty = true },
- telemetry = { enable = false },
- library = {
- "${3rd}/love2d/library",
- },
- diagnostics = {
- globals = { 'vim', 'table', 'love' },
- disable = { "lowercase-global" }
- },
- capabilities = lsp_capabilities
- }
- }}
- vim.api.nvim_create_autocmd('LspAttach', {
- desc = 'LSP Actions',
- callback = function()
- local bufmap = function(mode, lhs, rhs)
- local opts = {buffer = true}
- vim.keymap.set(mode, lhs, rhs, opts)
- end
- -- Show documentation about hover keyword
- bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
- -- Go to definition
- bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
- -- Go to declaration
- bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
- -- Show implementations
- bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
- -- Go to type definition
- bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
- -- List references
- bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
- -- Show function arguments
- bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
- -- Rename symbol
- bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
- -- List "code actions" at the position
- bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
- -- Show line diagnostics
- bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
- -- Go to previous diagnostic
- bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
- -- Go to next diagnostic
- bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
- end
- })
- -- Mic options
- vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
- vim.opt.number = true
- vim.g.mapleader = ","
- -----tab width
- vim.opt.tabstop = 4
- vim.opt.shiftwidth = 4
- vim.opt.expandtab = true
- -- CMP configuración
- local cmp = require('cmp')
- local luasnip = require('luasnip')
- local select_opts = {behavior = cmp.SelectBehavior.Select}
- cmp.setup({
- snippet = {
- expand = function(args)
- luasnip.lsp_expand(args.body)
- end
- },
- sources = {
- {name = 'path'},
- {name = 'nvim_lsp', keyword_length = 1},
- {name = 'buffer', keyword_length = 3},
- {name = 'luasnip', keyword_length = 2},
- },
- window = {
- documentation = cmp.config.window.bordered()
- },
- mapping = {
- ['<Tab>'] = cmp.mapping.confirm({ select = true }), -- Confirmar con <CR>
- },
- })
- -- For LOVE2D
- local function run_love_in_new_terminal()
- local current_dir = vim.fn.getcwd()
- local command = "taskkill /f /im love.exe & start cmd.exe /c love " .. vim.fn.shellescape(current_dir) .. " --console"
- print(command)
- vim.fn.system(command)
- end
- vim.api.nvim_create_user_command(
- "OpenLove",
- run_love_in_new_terminal,
- {}
- )
- -- Save and Run Love Project in the current dir
- vim.api.nvim_set_keymap('n', '<leader>l', ':w<CR>:OpenLove<CR>', { noremap = true, silent = true })
- -- Open Tree
- vim.api.nvim_set_keymap('n', '<C-t>', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
- -- For reload config file (init.lua)
- vim.api.nvim_set_keymap('n', '<C-r>', ':so $MYVIMRC<CR>', { noremap = true, silent = true })
- -- Colors scheme
- vim.opt.termguicolors = true
- vim.cmd.colorscheme('tokyonight')
Add Comment
Please, Sign In to add comment