### Configuring plagin in Lua file

Some plugins need to be configured to work. These configurations are done in Lua. As a rule, you can find the configuration on GitHub for each plugin, we just need to copy it or modify it according to our preferences and save it in the files where we have Neovim.

We have two options how to save such configuration. Either in the `init.vim` file or for better clarity in a lua file where each plugin will have its own file.

##### First way:

This is the simpler way of configuring it by adding it to `init.vim`.

1. In the 'init.vim' file, create the following two tags:

    lua << EOF

    EOF

1. And insert the config itself between them, for example as follows:

    lua << EOF
    -- nvim-lightbulb setup
    require('nvim-lightbulb').setup({
      autocmd = { enabled = true },
    })
    EOF

Next, we add the individual 'lua << EOF' 'EOF' tags to the subwebs and inject the configurations into them.

##### Second way:

This way is a bit more complicated, but it will help to organize the configuration files and have a better overview.

1. add this line to the 'init.vim' file:

    lua require('kankys')

With this, we've imprinted a file into which we will import each configuration.

1. In the Neovim folder where we have the 'init.vim' file, we create the 'lua' folder.

2. In the 'lua' folder, create a folder with your nickname or whatever you like. In my case I chose 'kankys'.

You should now have this structure: '~/.config/nvim/lua/kankys/'

1. In the 'kankys' folder, create a file:

    init.lua

We will import the individual configurations into it.

1. We will create a file with the name of the plugin with the lua extension that we want to configure.

For example, I will want to configure the plugin 'gitsings'.

1. We will create the file 'gitsings.lua' in the 'kankys' folder. Into it we put the configuration according to the Github instructions for the plugin.

The file will then look like this:

    require('gitsigns').setup {
        -- signs config
        current_line_blame = true,
        current_line_blame_opts = {
            virt_text_pos = 'right_align'
        }
    }

And save it.

1. Send the point to import the configuration into 'init.lua' We open the file 'init.lua' and paste into it:

    require('kankys/gitsigns')

And save the file.

This is how we will add more imports to 'init.lua'.

Copyright © 2024 - 2025 🚀 ApolloNvim / Lukáš Kaňka